본문 바로가기
기술자료/C#

예외처리 1 : try catch 문법

by 와이즈캣 2021. 6. 10.
728x90
반응형
class Program
{
    static void Main(string[] args)
    {
        int iNum;
        while (true)
        {
            try
            {
                Console.WriteLine("정수를 입력하세요.");
                iNum = int.Parse(Console.ReadLine());

                Console.WriteLine("정수를 입력했습니다.");
                break;
            }
            catch (Exception)
            {

                Console.WriteLine("정수를 입력하지 않았습니다.");
            }
        }
            
    }
}

 

 

728x90