Recently i faced this question, "Where memory for static variables will be allocated?"
When a static variable is allocated, it will be stored as part of Methodtable. When a class is loaded first time in application, separate memory will be allocated in appdomain for class level variables and methods inside class. This data structure is called Methodtable.
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.
C# Interview Questions and Answers · · · ·