Types in c#.

Their are mainly 2 types
a) Value Types – Integer,double ,enums etc are value types.
When a variable is declared using one of the basic, built-in data types or a user-defined structure, it is a value type.
A value type stores its contents in memory allocated on the stack .
b) Referance Types – Interfaces,arrays,strings,object are reference types.
— Initial value for reference type is Null and for value, type is 0
A reference type, such as an instance of a class or an array, is allocated in a different area of memory called the heap.
This memory isn’t returned to the heap when a method finishes; its only reclaimed when C# garbage collection system determines it is no longer needed.



Comments