IO 使用try catch 自动错误跳转

1,以下代码显示被除0的错误提示

 

代码如下:

View Code
static void Main(string[] args)
        {

           
int aa =Console.In.Read();
           Console.Out.Write(aa);
           Console.ReadLine();
           
int a = 10;
           
int b = 0;
           
try
           {
               
int c = a / b;
           }
           
catch(DivideByZeroException exe)
           {
               Console.WriteLine(exe.Message
+"  "+"不能被整除");
               Console.WriteLine(exe.HelpLink);
               Console.WriteLine(exe.Source);
               Console.WriteLine(exe.TargetSite);
               Console.WriteLine(exe.ToString());
           }
           Console.ReadLine();
            
        }

 

 

posted on 2011-07-30 22:52  wtq  阅读(366)  评论(0编辑  收藏  举报