<1> has two very important exception classes that derive from the System.Exception class
System.SystemException: The class is usually thrown by the. NET runtime, or has a very general nature and can be thrown by almost all applications, and the subclass of the system.systemexception exception includes exceptions that represent fatal and non-fatal errors;
System.ApplicationException: This class is very important because it is a third-party defined exception base class, and if any exceptions that you define override the application's unique error conditions, you should make them derive directly or indirectly from the System.ApplicationException class;
<2>try...catch...finally to perform the steps:
1. The executed procedure flows into the try block;
2. If no exception occurs in the try block, the operation will be performed normally in the block. When the program flow reaches the end of the try block, if there is a finally block, the program flow automatically enters the finally block, but if an error is detected in the try block, the program flow jumps to the catch
3. Handling errors in the catch block;
4. After the catch block executes, if there is a finally block, the program flow automatically enters the finally block;
5. Execute the finally block;
Note: You can omit the finally block; you can provide any number of catch blocks to handle different types of errors, but should not contain too many catch blocks to reduce application performance
<3> Note
1. After an exception occurs, code in the try block after the exception code does not execute
Code in 2.finally blocks, whether or not an exception occurs, executes before a return in a try or catch
Cannot write return statement in 3.finally block
A return statement is in the 4.try block, and finally is executed and executed before the return;
5. Even if there is no code in the catch,finally will execute, but finally the code will not be executed;
C # Errors and exceptions