memory allocation for value type inside reference type in .net

But what about value types present inside a class (reference type)? Where are they stored and how are they accessed?

Value types are stored where they are declared. In your case, they will be on heap.

But you should see the following articles with respect to memory management in C#.

The Truth about value types - Eric Lippert

in the Microsoft implementation of C# on the desktop CLR, value types are stored on the stack when the value is a local variable or temporary that is not a closed-over local variable of a lambda or anonymous method, and the method body is not an iterator block, and the jitter chooses to not enregister the value.

The Stack Is An Implementation Detail, Part One - Eric Lippert
Memory in .NET - what goes where - Jon Skeet

Tags:

C#

.Net