일단 C# 기준으로 묻는건데,

아래 주석대로의 영역에 생성되는거 맞나요?


    class testClass {

        int a;                  // 스택

        string b = "a";         // 스택+기타?

        int[] c = new int[30];  // 힙

    

        public void function(){

            int a;                  // 스택

            string b = "a";         // 스택+기타?

            int[] c = new int[30];  // 힙

        }

    }

    public partial class Form1 : Form {

        public Form1() {

            InitializeComponent();

        }


        int a;                  // 스택

        string b = "a";         // 스택+기타?

        int[] c = new int[30];  // 힙

        private void Form1_Load(object sender, EventArgs e) {


            testClass TT = new testClass(); // 힙


            int a;                  // 스택

            string b = "a";         // 스택+기타?

            int[] c = new int[30];  // 힙

        }

    }


저렇게 그냥 어디서 선언하건 저 스코프 정도면 다 스택인가여?
클래스 멤버변수든 함수 지역변수든 다?

저기서 "기타?"라고 한건 어딘지 정확하게 몰라서 그럼.
b라는 변수는 스택일건데, "a"라는 문자열은 어디 저장되나여?


그리고

    static class Program {
        /// <summary>
        /// 해당 응용 프로그램의 주 진입점입니다.
        /// </summary>
        [STAThread]
        static void Main() {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Form1());
        }

        int a;                  // 데이타
        string b = "a";         // 데이타+기타?
        int[] c = new int[30];  // 힙

    }


위 구문은 기본적으로 생성되는 메인구문인데,

저 위치에 선언하면 static으로 취급되나여? 아니면 그냥 첫번째 예시와 같이 스택기준이 되나여?



아, 그리고 스택이 좋은건

CPU L1~L3 캐시에 잘 들어가서 그런거 맞죠?

그거 빼면 똑같고?