Where are static members stored in memory? stack/ heap in C# .Net

This question already has an answer here:

  • Fields of class, are they stored in the stack or heap? 3 answers

  • When a static variable is allocated, it will be stored as part of Methodtable. Methodtable means When a class is loaded first time in application, separate memory will be allocated in appdomain for class level variables and methods inside class. .

    If static variable is primitive type, it will be stored as part of Methodtable. If it is reference type, it will be stored inside the heap and the reference will be stored in Methodtable

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

    上一篇: 免费商店“堆”这个词的起源是什么?

    下一篇: 静态成员在内存中存储在哪里? 堆栈/堆在C#.Net