S_pot

C#_while 반복문 본문

C#

C#_while 반복문

S_pot 2021. 5. 31. 22:23

 

static void Main(string[] args)
        {
            // 조건이 참이면 무한반복한다.
            while(true)
            {
                Console.WriteLine("무한 반복");
            }
        }

 

static void Main(string[] args)
        {
            // 변수선언
            int i = 0;
            int[] intArray = { 52, 273, 32, 65, 103 }; // 0번째, 1번째, 2, 3, 4

            // 반복수행
            while (i < intArray.Length)
            {
                Console.WriteLine(i + "번째 출력:" + intArray[i]);

                // 탈출을 위해 변수를 더한다.
                i++;
            }
        }

 

'C#' 카테고리의 다른 글

C#_for 반복문  (0) 2021.05.31
C#_do while 반복문  (0) 2021.05.31
C#_배열문  (0) 2021.05.31
210513 C#_참 거짓 위치에 불 자료형/문자열 자료형 사용  (0) 2021.05.31
210513 C#_switch문  (0) 2021.05.31