-
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?
-
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"]);
-
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?
-
Yes, because you are storing a pointer (reference) to the object in the hashtable.