What are the fundamental differences between value types and reference types?

C# divides types into two categories - value types and reference types. Most of the basic intrinsic types (e.g. int, char) are value types. Structs are also value types. Reference types include classes, interfaces, arrays and strings. The basic idea is straightforward - an instance of a value type represents the actual data (stored on the stack), whereas an instance of a reference type represents a pointer or reference to the data (stored on the heap).
The most confusing aspect of this for C++ developers is that C# has predetermined which types will be represented as values, and which will be represented as references.


Comments

Author: Deepika Haridas27 Dec 2008 Member Level: Gold   Points : 1

Hi,
Good post..
Very Useful..
Thanks a lot for posting it..!!

Regards,
Deepika



  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: