C # Exception Class related summary

Source: Internet
Author: User

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

Related Article

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.