전역변수1 [C#][Study][기초다지기] static static - 클래스 내의 함수나 변수는 클래스가 객체를 생성할 때까지 메모리에 인스턴스가 생성되지 않는다. - 그러나 static을 사용해 함수나 변수를 선언하면, 메모리에 인스턴스가 직접 생성되고, 전역적으로 작동한다. - 또한 어떠한 객체도 참조하지 않는다. using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Static_var_and_fun { class number { public static int num; // 정적 변수 선언 public static void power() // 정적 함수 선언 { Console.WriteLine("Power of {0} = {1}", n.. 2023. 9. 23. 이전 1 다음