案例代码如下:
class MyClass { public void A() { try { B(); } catch (System.NullReferenceException) {Console.WriteLine("catch clause in A()"); } finally { Console.WriteLine("finally clause in A()"); } } private void B() { int x = 10, y = 0; try { x /= y;//除数不能为0; } catch (System.IndexOutOfRangeException ) { Console.WriteLine("catch clause in B()"); } finally { Console.WriteLine("finally clasue in B()"); } }