3.5. Types
The .NET Framework class library supports two groups of types:
value types;
reference types.
The major distinction between these two groups is that value types are allocated on the stack, while reference types are stored in the heap.
Value types cannot be null and must always contain data. That's why for each value type there is always a default value. Value types are always passed by value – that is, in our functions, we always deal with the copy of the value, leaving the original value unchanged. Most of the value types are not more than 12 to 16 bytes in size – as they are located in the stack, they should not consume much memory.
Reference types are used to represent data structures that may consume significant memory resources. ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access