9.20,异常语句

                                       

          //异常语句,平时一般不用
              try
              {//y要包括起来的可能有错误的代码
                  int a = int.Parse(Console.ReadLine());
              }
              catch (Exception ex)//抓取错误
              {
                  throw ex;//ex,存取的异常错误 
                  Console .WriteLine ("出现的错误:"+ex .Message );
              }
              finally//可以没有,只有try,catch
              { //不管程序有没有错,都会执行
                  Console.WriteLine ("hellow world");
              }
              Console.ReadLine(); 

try 

{}

catch(exception ex)

{}

finaly

{]

posted @ 2015-09-20 14:39  小热包1  阅读(136)  评论(0编辑  收藏  举报