|
-
Apr 21st, 2003, 04:27 PM
#1
Thread Starter
yay gay
Reference types
If i make a reference to a refence type then if i make another reference to the same object and change it, the inicial one will be changed as they point to the same object right? if i have 2 or more hashtables that point to the same object, they are not creating new objects but just making references to the other object right?
\m/  \m/
-
Apr 22nd, 2003, 03:56 AM
#2
Huh?
If you mean something like this, it works:
Code:
System.Collections.Hashtable table1 = new System.Collections.Hashtable();
System.Collections.Hashtable table2 = table1;
table1.Add("keyString", "dataString");
System.Console.Println(table2["keyString"]);
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Apr 22nd, 2003, 11:05 AM
#3
Thread Starter
yay gay
myClass mClass = new myClass();
Hashtable h1 = new hashtable();
hashtable h2 = new hashtable();
h1.add("class", mClass);
h2.add("class", mClass);
//now i make something like:
h1["class"].SOmething = 5;
//will now h2["class"].something be 5 too?
\m/  \m/
-
Apr 22nd, 2003, 11:50 AM
#4
PowerPoster
Yes, because you are storing a pointer (reference) to the object in the hashtable.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|