본문 바로가기
c#/메모장

while문 기본

by 이지훈26 2021. 8. 23.

using System;

namespace HelloWorld
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = 0;
            while (n < 5)
            {
                Console.WriteLine(n);
                n++;
            }
        }
    }
}

--------------------------------------------------------------------------

using System;

namespace HelloWorld
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = 0;
            while (true)
            {
                if (n == 5)
                {
                    break;
                }
                Console.WriteLine(n);
                n++;
            }
        }
    }
}

 

-----------------------------------------------------------------------------

반복하여 외울것.

'c# > 메모장' 카테고리의 다른 글

산술연산자 독스  (0) 2021.08.24
Method - 만든문제  (0) 2021.08.24
메서드 정리 및 복습 해보기  (0) 2021.08.23
  (0) 2021.08.23
정리  (0) 2021.08.20