Value Type & Reference Type in C#

These two data types are important for the performance of the applications. Built in data types like int, float, double and user defined structure are value types. Value type is stored in stack of the memory.

String data type is the execption that it is reference type. Additionally instance of a class or an array are the reference types. Reference types are stored in heap of the memory.

For the performance issues using stack is more effient. However, value types have limited lifetime, so using stack may not be convenient for data sharing between different classes.  Using heap has advantage for sharing the data between classes.

 

This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s