about value and reference type

In value type based variables holds memory on stack and hold fixed space for example integer in dot net hold 4 bytes.

In reference type based variables holds memory at managed heap. Reference type variables hold dynamic space. The space hold by reference type can be vary.

When reference is to assign to variable. Only reference is stored in variable. Where this reference is refer actual memory is stored in heap where actual value or data is placed.

Stack is small area of memory where fixed no of space is reserved . for example integer , double always contain same area of memory. So they placed in stack.

While heap is dynamic memory where variable for example string can hold 2 bytes or it contain all available of physical memory

One thought on “about value and reference type

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