Data Types and Boxing

After our introduction to C#, we continue with an additional topic that's important to most programmers: managing data types.

Value Types and Reference Types

C# provides both value types and reference types. The difference between them is a fundamental concept. In strictly object-oriented languages, every variable is an object. In contrast to variables you might know from procedural languages, objects are far more complex and lead to some overhead. When somebody allocates an integer variable in C/C++, 4 bytes are allocated on the stack. But when an instance of an object is created, far more memory is needed to store all the administrative information.

To raise performance, C# defines a difference between variables storing ...

Get Mono Kick Start now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.