/异常语句 /* try { int a = int.Parse(Console.ReadLine()); } catch (Exception ex) { //throw ex; Console.WriteLine("出现错误了" + ex.Message); } finally //可省略 { Console.WriteLine("hollo"); } */ //实例 //必须通过new初始化,后面括号实际是构造函数 //DateTime实际是一个类-class int cuo = 0; Console.Write("输入日期"); string s = Console.ReadLine(); try { //DateTime dt = new DateTime(2015, 9, 14); DateTime dt = DateTime.Parse(s); } catch (Exception ex) { Console.WriteLine("不是"); cuo = 1; } if (cuo == 0) { Console.WriteLine("正确"); } //Console.Write(dt.ToString()); Console.ReadLine();