捕捉异常 (Visual C#)

C#
int top = 0, bottom = 0, result = 0;

try
{
    result = top / bottom;
}
catch (System.Exception ex)
{
    System.Console.WriteLine("{0} exception caught here.", ex.GetType().ToString());
    System.Console.WriteLine(ex.Message);
}
finally
{
    System.Console.WriteLine("Clean-up code executes here...");
}
System.Console.WriteLine("Program execution continues here...");

输出

System.DivideByZeroException exception caught here.
Attempted to divide by zero.
Clean-up code executes here...
Program execution continues here...
 
阅读更多
文章标签: c# exception
上一篇几个C#常用正则表达式
下一篇窗体中控件自动随窗体变化大小
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

关闭
关闭