Common Type System—Memory Layout
| CSharp-Online.NET:Articles |
| .NET Articles |
|
| © 2006 Wiley Publishing Inc. |
Memory Layout
Let’s briefly consider the memory layout for objects and values. It should help to illustrate some of the
fundamental differences. Consider if we had a class and a struct, both containing two int fields:
class SampleClass { public int x; public int y; } struct SampleStruct { public int x; public int y; }
They both appear similar, but instances of them are quite different. This can be seen graphically in Figure 2-2, and is described further below.

Figure 2-2: Object and value memory layout.
You’ll immediately notice that the size of a value is smaller than that of an object.
|

