Thursday, September 9, 2010

Structure are Reference type or value type

Structures are value type.
Structs are value types, while classes are reference types, and the runtime deals with the two in different ways
When a value-type instance is created, a single space in memory is allocated to store the value. Primitive types such as int, float, bool and char are also value types, and work in the same way. When the runtime deals with a value type, it's dealing directly with its underlying data and this can be very efficient, particularly with primitive types.
With reference types, however, an object is created in memory, and then handled through a separate reference—rather like a pointer.

Share This!


No comments:

Powered By Blogger · Designed By Seo Blogger Templates