Where is the memory area of the reference static variable in c#?

Asked 2 months ago, Updated 2 months ago, 380 views

Are reference static variables in c# stored in static, heap, or stack areas?


2023-01-22 06:04

1 Answers

There are only two types of C#: reference type and value type.There are also two types of memory space managed by GC: heap or stack.

  • All referenced objects reside on the heap and are managed by GC.
  • Value types vary depending on the situation.Often present in the stack, but in some cases on heap and managed by GC.

Rather, I recommend that you study English without blindly accepting katakana.
I think that "static" is supposed to be either stack or static, but since "stack" or "static" appear in the question sentence, I can't read which intention it is.
The variable is also variable, which refers to what is declared in the method.
In other words, the English translation of the reference static variable is reference type (stack | static) variable but it doesn't make sense at all. (Reference type cannot exist in stack, variable cannot be static)

2023-01-22 10:43

If you have any answers or tips

© 2023 OneMinuteCode. All rights reserved.