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

前端 未结 3 1627
情歌与酒
情歌与酒 2020-11-29 00:42

I saw a question yesterday which raised (for me) another question. Please look at the following code:

public class Class1
{
   int A; //as I uderstand, int i         


        
3条回答
  •  不知归路
    2020-11-29 01:34

    Local struct (value type) variables are stored on the stack, value type fields of a class are stored on the heap.

提交回复
热议问题