Thursday, May 15, 2008

Value Type & Reference Type in .NET

Object, variables; declared in .NET Compatible languages; requires data type to be specified. Data types specifies what kind of data (textual or numeric or complex) can be stored in the object/variable.

Data types in .NET are categorized in two types: Value Type and Reference Type.

Value type variables are allocated on stack & directly store the data value. Value-types cannot be assigned to null value. Value type variable vanish when they go out-of-scope (visibility).

Value types are : all primitive system types(int, float etc.) and structures, enumerations.

Reference types are allocated on heap. Value gets stored in heap. The address of memory location, having value, gets stored in stack in memory location tagged with the object/variable. Heap is garbage collected. Reference type variables/objects can be assigned null value.

Reference types: Classes, Delegates, Arrays and Interfaces
Post a Comment