Coding Villa Forum
FAQs
Advertisements

Difference between Value type and Reference type

Nadeem Online 5/31/2012 11:26:05 AM

Hello Friends!

I want to know what is the Difference between value type and reference type?Please friends guide me and try to  explain difference with examples.

Thanks

Share with Friends

Advertisements

Answer

Nadeem Online 5/31/2012 12:00:47 PM

Good

Answer

Zaryab Online 5/31/2012 5:44:21 PM

The value of x is a reference - it will either be null or a reference to an object which is itself an instance of SomeReferenceType or a derived class. The value of x is not, in itself, the object.

The value of y is the data itself - if SomeValueType has three fields, the value of y will directly contain those fields.

That's a very brief summary - see Eric Lippert's blog post about value types and my article for more information. (You might also be interested in my article about parameter passing which is related, but not quite the same.)

Answer

Iram Online 6/5/2012 12:34:26 PM

Hello,

Yes Zaryab is right value type variables store value directly whereas reference type contains the reference of another variable that is stored on managed heap. I want to add here another main difference between value type and reference type that is, Value types are stored on the stack whereas reference types are stored on managed heap.
Share with Friends

Post reply

 

Enter This Code
Captcha
 

Subscribe

Email me when people reply


Subscribe to the