利用try退出

来源:互联网 发布:aim120 pl12知乎 编辑:程序博客网 时间:2024/06/05 05:22
       static void Main(string[] args)        {            while (true)            {                try                {                    Test();                }                catch (Exception e)                {                    Console.WriteLine(e.Message);                }             }        }        static void Test()        {            Console.WriteLine("输入exit退出");            string input = Console.ReadLine().ToLower();            if (input == "exit")                throw new Exception("退出成功");            Console.WriteLine(input);                    }       

0 0
原创粉丝点击