1 using System;
2 using System. Collections. Generic;
3 using System. Linq;
4 using System. Text;
5
6 namespace ConsoleApplication2
7 {
8 class Program
9 {
10 static void Main (string [] args)
11 {
12 // Level1
13 try
14 {
15 // Level2
16 try
17 {
18
19 // Level3
20 try
21 {
22 // throw new effectiona ("Exception in Level3 ");
23 // throw new ExceptionB ("Exception in Level3 ");
24}
25 catch (effectiona)
26 {
27 Console. WriteLine ("handling Exception in Level3 ");
28}
29 finally
30 {
31 Console. WriteLine ("finally statement block in Level3 ");
32}
33 throw new ExceptionC ("Exception in Level2 ");
34}
35 catch (ExceptionB)
36 {
37 Console. WriteLine ("handling Exception in Level2 ");
38}
39 finally
40 {
41 Console. WriteLine ("finally statement block in Level2 ");
42}
43 // throw new Exception ("Exception in Level1 ");
44}
45 catch (ExceptionC)
46 {
47 Console. WriteLine ("processing ExceptionC in Level1 ");
48}
49 catch (Exception)
50 {
51 Console. WriteLine ("handling Exception in Level1 ");
52}
53 finally
54 {
55 Console. WriteLine ("finally statement block in Level1 ");
56}
57
58
59 Console. ReadKey ();
60
61}
62}
63}
1 using System;
2 using System.Collections.Generic;
3 using System.Linq;
4 using System.Text;
5
6 namespace ConsoleApplication2
7 {
8 class ExceptionA : Exception
9 {
10 public ExceptionA(string mess):base(mess)
11 {
12 }
13 }
14 }
First, check for compatibility exceptions at the same level.