Value Types and Reference Types in .Net

Value Types and Reference Types in .Net

A data type is a value type if it holds the data within its own memory allocation. A reference type contains a pointer to another memory location that holds the data.

All the data types in .net are classified in to value types and reference types.

The data types whose values are directly stored in stack memory area are called as value types and the data types whose values are stored in heap memory area and its address is stored in a variable in stack memory area are called as reference types.

Among all built in data types of .net string and object are reference type and all other data types are value types.

Among user defined data types, class, interface, delegate and arrays are reference type while structure and enumeration are value type.