C # exception sorting...

Source: Internet
Author: User
1. Overall Mode

PS: all the preceding exceptions are in the system namespace, except for ioexception and its derived excpetion in system. Io.
We can see that there are two types of exceptions: systemexception and applictaionexception.
Systemexception: usually generated by the. NET Runtime Library
Applictaionexception: a base class for user-defined exceptions. It can be used to define some unique exceptions of an application.

2, systemexception
Most of them can be guessed by their names.
Stackoverflowexception: such exceptions often occur in recursive and endless loops, resulting in the memory area allocated to the stack being full. In this case, the finally region is not even executed.
Overflowexception: for example, in the checked environment, to convert-40 int to uint data, the base class is the base class for computing exceptions.
Other words can be guessed.

3, applicationexception

Public class pagecannotfindexception: applicationexception {public pagecannotfindexception (string pagename): Base ("cannot find page:" + pagename) {} public pagecannotfindexception (string pagename, exception innerexception ): base ("cannot find page:" + pagename, innerexception) {}} is a simple user exception class.

The usage is basically the same as the predefined
Capture:

try{...}Catch(PageCannotFindException  ex){...}

Throw:

Catch(Exception ex){throw new PageCannotFindException(pageName, ex);}

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.