C # Exception class related summary
When doing exception handling, it is best to use try-catch at all entrances to the application (event handlers, main functions, thread portals). But do not add try-catch at the entrance of the program constructor, because there is an exception here, it does not have the ability to handle it, because it has not been constructed and can only throw an exception to the outer layer.
C # Exception Class One, base class exception
C # exception Class II, common exception classes
1 , SystemException Class : This class is the base class for all other exception classes in the System namespace. (Recommended: Exceptions thrown by the common language runtime typically use this class)
2 , ApplicationException class: This class represents the exception that is thrown when an application has a non-fatal error (recommendation: The exception that is thrown by the application itself is typically used in this class)
C # Exception Class three, the exception class related to the parameter
This class of exception class is derived from SystemException, which is used to handle arguments passed to a method member when an exception occurs
1. ArgumentException Class: This class is used to handle exceptions with invalid arguments, in addition to inherited property names, this class also provides a string type of property paramname that represents the name of the parameter that threw the exception.
2. FormatException class: This class is used to handle exceptions with malformed parameters.
C # Exception class Iv. exceptions related to member access
1. Memberaccessexception class: This class is used to handle the exception that is thrown when a member of an Access class fails. The reason for the failure may be that there is insufficient access, or that the member to be accessed does not exist at all (calls between classes are often used)
2. Direct derived classes of the Memberaccessexception class:
I, Fileaccessexception class: This class is used to handle exceptions thrown by accessing field member failures
II, Methodaccessexception class: This class is used to handle exceptions thrown by access method member failures
III, MissingMemberException class: This class is used to handle exceptions that are thrown when a member does not exist
C # Exception Class v. Array-related exceptions
The following three classes are inherited from the SystemException class
1. Indexoutofexception class: This class is used to handle exceptions caused by subscript exceeding the length of the array
2. ArrayTypeMismatchException class: This class is used to handle exceptions thrown by elements that store incorrect data types in an array
3. Rankexception class: This class is used to handle exceptions caused by dimension errors
C # Exception Class VI, and IO about the exception
1. IOException Class: This class is used to handle exceptions that are thrown when file input and output operations are performed.
2.5 Direct derived classes of the IOException class:
I, Directionnotfoundexception class: This class is used to handle exceptions that are thrown when a specified directory is not found.
II, FileNotFoundException class: This class is used to handle exceptions that are thrown when a file is not found.
III, EndOfStreamException class: This class is used to handle the exception that is thrown when the end of the stream has been reached and continues to read the data.
IV, FileLoadException class: This class is used to handle exceptions that are thrown when a file cannot be loaded.
V, PathTooLongException class: This class is used to handle exceptions that are thrown because the file name is too long.
C # Exception class seven, arithmetic-related exceptions
1. ArithmeticException class: This class is used to handle arithmetic-related exceptions.
2. Derived classes of the ArithmeticException class:
I, DivideByZeroException class: Represents an exception that is thrown when an integer in the decimal operation attempts to divide by 0.
II, NotFiniteNumberException class: Represents the exception that is thrown when an infinite or non-negative value occurs in a floating-point operation.
Original article connection: http://www.cnblogs.com/goody9807/archive/2012/09/04/2670753.html
C # Exception Class related summary