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);}