哪位有关于c#异常的习题。谢谢!

来源:百度知道 编辑:UC知道 时间:2024/06/30 22:00:55

Exception 类
表示在应用程序执行期间发生的错误。

using System;

class ExceptionTestClass
{
public static void Main()
{
int x = 0;
try
{
int y = 100/x;
}
catch (ArithmeticException e)
{
Console.WriteLine("ArithmeticException Handler: {0}", e.ToString());
}
catch (Exception e)
{
Console.WriteLine("Generic Exception Handler: {0}", e.ToString());
}
}
}