Memory structure for reference and value types

I am new to c# and now in learning phase .I got confused with reference and value types . I google on this but did not find an answer which makes me understand .

Here is my class . I want to know how all this types are getting stored inside heap/stack .

class Demomemory
{
      int var ;
      string strVar ;
      public DemoClass DC = new DemoClass(); //Another class object
      public Demomemory(int x ,int y)
      {
         int z = x+ y ;
      }
}

Can anyone please tell me with some diagram how the above variables(var , strVar , DC , x , y , z) are getting stored inside memory . I usually see some statements like DC is reference to the actual object . What exacly is this reference .

I am new to c# , So please help me on this . Thanks in advance .


I want to know how all this types are getting stored inside heap/stack .

You need not go anywhere other than Eric Lippert's article here. It discusses every bit of value and reference type in detail.

链接地址: http://www.djcxy.com/p/82598.html

上一篇: 变量如何存储在堆栈上?

下一篇: 内存结构用于参考和值类型