473,405 Members | 2,334 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Basic Object Copy Question

All -

I want to be able to set one generic variable to the instance of another...

So lets say I have an object named objFoo that is initialized as a generic
object of type Object. Now I get returned to me a TreeView Node object
called objNode. How do I set my generic objFoo to objNode? objFoo =
objNode; doesn't seem to work.

Thanks in advance.

- Matt

Nov 16 '05 #1
1 1429
Node TreeNode = TreeView.Nodes[0];
object Foo = new object();
Foo = TreeNode;

Treenode = Foo as TreeNode;

If the object Foo was pointing to was of type TreeNode (Which in the above
sample it is) this will work.
If not then in the above sample TreeNode will equal null.
You cannot set TreeNode to a generic object. (Dont know why you would want
to).

so you cannot do
TreeNode = new object() as TreeNode;
(You can but TreeNode will equal null)

HTH
JB
If you explain what you are trying to accomplish maybe we can help you
better.

"Matthew Sajdera" <MS******@Cox.net> wrote in message
news:ec**************@TK2MSFTNGP11.phx.gbl...
All -

I want to be able to set one generic variable to the instance of another...
So lets say I have an object named objFoo that is initialized as a generic
object of type Object. Now I get returned to me a TreeView Node object
called objNode. How do I set my generic objFoo to objNode? objFoo =
objNode; doesn't seem to work.

Thanks in advance.

- Matt

Nov 16 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Brian | last post by:
I am "learning" C# and have run into a problem that, though I can work around it, I would like to know what the *right* way to handle the issue is. I have created an "Info" struct and assigned...
4
by: gg9h0st | last post by:
i worte a simple code below. ------------------------------------------------------------------------------------ #include "stdafx.h" class Object { public: int a;
3
by: Simon Hart | last post by:
Hi, I am trying to implement some functionality as seen in MS CRM 3.0 whereby a basic Xml is deserialized into an object which contains properties. What I want to do from here is; cast the basic...
5
by: Vijay | last post by:
Hi All, I am not able to figure out what exactly happening in below code. what is control flow. Can anyone clear my confusion? Code: class A { public: A(){cout<<"In Constructor\n";}
3
by: Tenowg | last post by:
Hey guys, I know this is probably a very easy, basic question, so feel free to direct me to a detailed answer. I have done some searches some some of the information I get is vague. In C#, the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.