If you are looking to do performance tuning, there are a lot of different tools to help you find and optimize ASP. A lot of confusion has been wrought by people explaining the difference between value types and reference types as "value types go on the stack, reference types go on the heap".

just4udating net-5just4udating net-34

Just4udating net video

The slot of memory is large enough to contain both integers (so it must be 8 bytes).

Note that a value type variable can never have a value of is a reference type concept, meaning "the value of this reference type variable isn't a reference to any object at all".

The memory slot for a variable is stored on either the stack or the heap.

It depends on the context in which it is declared: There are a couple of exceptions to the above rules - captured variables (used in anonymous methods and lambda expressions) are local in terms of the C# code, but end up being compiled into instance variables in a type associated with the delegate created by the anonymous method.

The same goes for local variables in an iterator block.

The above may all sound a bit complicated, but a full example should make things a bit clearer.Here's a short program which does nothing useful, but should demonstrate the points raised above.A variable has a value, which is the contents of the memory slot it's associated with.The size of that slot, and the interpretation of the value, depends on the type of the variable - and this is where the difference between value types and reference types comes in.The value of a reference type variable is always either a reference or .) The slot of memory associated with the variable is just the size of a reference, however big the actual object it refers to might be. NET, for instance, a reference type variable's slot is always just 4 bytes.) The value of a value type is always the data for an instance of the type itself.For instance, suppose we have a struct declared as: is the pair of integers itself, not a reference to a pair of integers.