In my previous question (regarding adding items to ArrayList) one of the posters wrote that “reference is already an object” – how it was meant? I do not get it. I thought reference is just an address of the object that I can pass:
object X=5;
object A=X; //here I am assigning reference to X so both are pointing to copy of 5
Also with the ArrayList example, it actually stores references..but again I got confused with comment “System.Object” reference type. What does it mean?
I would be very grateful for simple examples. I do understand difference between value types and ref.types, however this is something I cannot figure out altough I know it works.
What you’ve done in your code is taken a value type and “boxed” it, so now it is a reference type on the heap which contains the value “5”. I would recommend you start out by trying to get an understanding of value/reference types in C#, mutability/immutability, and boxing/unboxing.
Here’s a good link to get you started: http://msdn.microsoft.com/en-us/library/yz2be5wk.aspx
Jon Skeet’s book “C# in depth” also does a good job on this (section 2.3.4).
Hope that helps.