ch2_18.cs
来自「《c#技术内幕代码》」· CS 代码 · 共 56 行
CS
56 行
using System;
class CH2_18
{
public static void CallExceptionFunction()
{
throw new Exception("This is an exception");
}
public static void Main()
{
try
{
// Call a function that throws an exception
try
{
CallExceptionFunction();
Console.WriteLine("This should never be printed");
throw new Exception("Bad Error Exception");
}
catch( Exception e)
{
Console.WriteLine("Catching the BadError Exception");
throw new Exception("Rethrowing", e);
}
finally
{
Console.WriteLine("Finally Statement #1");
}
}
catch ( Exception e)
{
Console.WriteLine("Catching Exception #2 {0}", e );
}
finally
{
Console.WriteLine("We are at the last outside nested block");
}
try
{
Console.WriteLine("No error will occur here");
}
catch ( Exception e )
{
Console.WriteLine("Caught an exception in a BAD place {0}", e );
}
finally
{
Console.WriteLine("This is the last finally block");
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?