Sunday, December 23, 2012

What are Value types and Reference types

Value Type:
When a value type instance is created a single location in memory is allocated to store the value. Primitive types such as int, double, float, bool, char are value types.

Reference Type:
When a reference type instance is created it handles through a separate reference. It acts just like a pointer. Meaning the memory address where your variable reside is actually holding another memory address. String is a reference type.

Note: Structs are value types, while classes are reference types

No comments:
Write comments
Recommended Posts × +