Exception Handling Mechanism

Source: Internet
Author: User
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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.