Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the C# exception classes

2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article is about what C# exception classes are about. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

C # exception class 1. Base class Exception

C # exception class II. Common exception class

1. SystemException class: this class is the base class for all other exception classes in the System namespace. (recommendation: exceptions thrown by the common language runtime usually use this class)

2. ApplicationException class: this class represents the exception that is thrown when a non-fatal error occurs in the application (it is recommended that exceptions thrown by the application itself usually use this class)

C # exception class III. Exception class related to parameters

Such exception classes are derived from SystemException and are used to handle exceptions when handling parameters passed to method members.

1. ArgumentException class: this class is used to handle exceptions with invalid parameters. In addition to inherited property names, this class also provides a property of type string ParamName that represents the name of the parameter that throws 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 exceptions that are thrown when members of the access class fail. The reason for the failure may be that there are not enough access rights, or the member to be accessed does not exist at all (often used in calls between classes)

2. The direct derivation of the MemberAccessException class:

I, FileAccessException class: this class is used to handle exceptions thrown when a failure to access a field member

Ii, MethodAccessException class: this class is used to handle exceptions thrown when access method members fail

Iii, MissingMemberException class: this class is used to handle exceptions thrown when a member does not exist

C # exception class 5. Array-related exceptions

The following three classes all inherit from the SystemException class

1. IndexOutOfException class: this class is used to handle exceptions when the subscript exceeds 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. IO-related exceptions

1. IOException class: this class is used to handle exceptions thrown during file input and output operations.

2. Five directly derived classes of the IOException class:

I, DirectionNotFoundException class: this class is used to handle exceptions that are thrown when the 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 exceptions that have reached the end of the stream and continue to read the data.

Iv, FileLoadException class: this class is used to handle exceptions that cannot be loaded.

V, PathTooLongException class: this class is used to handle exceptions thrown because the file name is too long.

C # exception class VII. Arithmetic-related exceptions

1. ArithmeticException class: this class is used to handle arithmetic-related exceptions.

2. The derived class of ArithmeticException class:

I, DivideByZeroException class: represents the exception that is thrown when trying to divide by zero in the decimal operation of integer goods.

Ii and NotFiniteNumberException classes: indicates the exception that is thrown when an infinite number or a non-negative value occurs in a floating-point operation.

Thank you for reading! This is the end of this article on "what are the abnormal classes of C#?". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report