Common Type System - Value Types vs Reference Types
Value Types and Reference Types are two basic types of CTS... Value Types
are allocated on the stack and Reference Types are allocated on Managed
heap... How this thing work is that the value of the "Value Types" is
allocated on the stack where as in case of "Reference Types" the value i.e.
the object itself resides in the heap but there is a pointer to the object
in the memory...
Considering this differences value types are faster but consume the process
memory.... Managed type don't consume this process memory but then they
become slower... When value types are copied then the whole object is copied
on the heap, when reference types are copied then only the reference is
copied... Inshort, there are pros and cons to both and sometimes you have an
option to choose one of them in your development sometimes you don't
have....
Value types are usually native data types like int, float, string, char,
enums etc... Reference types mostly include classes and some other user
defined types...Regards,Mitesh v. Mehta
Wednesday, August 11, 2004
Common Type System - Value Types vs Reference Types
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment