c#使用try{} catch(e){}捕获异常


c#使用try{} catch(e){}捕获异常

using System;
namespace HxRuntech
{
    public class T1
    {
        static void Main()
        {
            string? ageText;
            int? age;
            Console.Write("Enter you age:");
            ageText = Console.ReadLine();

            try
            {
                age = int.Parse(ageText!);
                Console.WriteLine(age);
            }
            catch (Exception ex) { 
                Console.WriteLine("please input the int number");
            }
        }
    }
}