Saturday, 4 August 2012

Using Common Reference Types in .NET

Most types in the .NET framework are reference types. These provide a great deal of flexibility and they offer excellent performance when passing them to methods. Reference types store the address of their data,also known as pointer on the stack. The actual data that address refers to is stored in area of memory called the heap. The runtime manages the memoryused by a heap through aprocess called garbage collection. Garbage collection recovers memory periodically as needed by decomposing of items that are no longer referenced . As reference types represent the address of data rather than data itself, assigning one reference  variable to another instance merely creates a second copy of the reference , which refers to the same memory location on theheap as the original value.  There are about 2500 built - in reference types in the .NET framework. Everything not derived from system.value type is reference type, including these 2500 or so built-in reference types.

    Various commonly used reference types are:-

1. System.string is used to text data.
2. System.Text.StringBuilder is used for dynamic text data.
3. System.Array is used for arrays of data. As it is the base class for all arrays.
4. System.IO.Stream is used to buffer for file.device and network I/O.

No comments:

Post a Comment