본문 바로가기
C#

While(반복문)

by Mostlove 2023. 7. 2.
728x90
반응형

While

namespace CSharp
{
    class Program
    {
        static void Main(string[] args)
        {
            int count = 5;
            while (count > 0)
            {
                Console.WriteLine("Hello World");
                count--;
            }
        
        }
    }
}

DoWhile

namespace CSharp
{
    class Program
    {
        static void Main(string[] args)
        {
            string answer;
            //거울아 거울아 ~
            do
            {
                Console.WriteLine("나는 잘생겼나욧?(y/n) : ");
                answer = Console.ReadLine();
            } while (answer != "y");
        }
    }
}

반응형

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

break, continue  (0) 2023.07.02
For문  (0) 2023.07.02
상수와 열거형  (0) 2023.07.02
가위 바위 보 게임!!  (0) 2023.07.02
분기문 (If/else if/else/switch/ 삼항연산자)  (0) 2023.07.02