-
clarification
Hello
I've just decided to add C# to my repetoire so I'm going through the language at the moment to iron out the differences between in and c++. At the moment I just need to clarify the value parameter of a method with perhaps an explanation of what's actually happening at the memory level:
Code:
IntHolder first = new IntHolder();
first.i=5;
IntHolder second = first;
first.i=6;
Console.WriteLine (second.i);
Output: 5
Now normally I would've thought that would produce a 6 since IntHolder second = first is a reference to the same object.
-
IntHolder is a struct, which means value type (no referenses). Had it been a class the output would be 6.