Wednesday, April 23, 2008

Best statement value types vs reference types

Value types comprise most build-in types(all numeric types, the char type and bool type), custom struct and enum types

Reference typs comprose all class, array, string delegate and inferface types.

Value types content is simply a value,
Reference type comtains Reference and object, when assigning a reference type variable copies the reference, not the object instance. This allows multiple variables to refer to the same object.
Reference type can be assigned null, value type can't.
Value type takes exactly the sum of memory of their fields takes.
Reference type takes object plus and reference memory, object meeory takes the sum of fields memory plus Oject metadata memory.

No comments: