Reference to class not working?
Hello,
I am running in a problem, I have a class called Test, and I create 10 instances of it. The class contains an integer.
public class Test
{
public Test(int init) { g = init; }
public int g;
}
Now, I set the current "test" instance:
Test current = "one of the 10 instances here";
Now.. if I modify the contents of the current instance after setting it as current, the current Test won't reflect these changes. For example:
Test current = inst1;
inst1.g = 100;
now, current.g doesnt contain 100, but the old value.. I am confused. Doesn't reference work that way? Also, how do I use WeakReference, and where is it suitable at? Sorry for so many questions.