About exception snapping in C #

Source: Internet
Author: User

List of exceptions in 1.c#

    

Exception: base class for all exception objects.  SystemException: base class for all errors generated by the runtime.  IndexOutOfRangeException: Thrown when the subscript of an array runs out of range.  NullReferenceException: Thrown when an empty object is referenced when it is run.  InvalidOperationException: Thrown by some methods when the caller's invocation is not valid for the current state of the object.  ArgumentException: base class for all parameter exceptions.  ArgumentNullException: Thrown by a method when the argument is empty (not allowed).  ArgumentOutOfRangeException: Thrown by a method when the parameter is not within a given range.  Interopexception: The base class for the exception in the environment where the target is or occurs outside the CLR.  COMException: An exception that contains HRESULT information for a COM class.  SEHException: Encapsulates exceptions for WIN32 structure exception handling information.    SqlException: Encapsulated SQL Operation exception. Common specific exception objects: ArgumentNullException An empty argument is passed to the method, and the method cannot accept the parameter argumentoutofrangeexception the parameter value is out of range arithmeticexception Arithmetic overflow or underflow arraytypemismatchexception attempting to store an object of the wrong type in an array badimageformatexception graphic error dividebyzeroexception except 0 exception Dlln Otfoundexception Unable to find referenced dll FormatException parameter format error IndexOutOfRangeException array index out of range InvalidCastException use invalid class Invali  Doperationexception method call time error NotSupportedException method called does not implement in class NullReferenceException attempt to use an unassigned reference OutOfMemoryException Insufficient memory space StackOverflowException stack Overflow

Try to catch the use of specific exceptions and avoid using system. Exception

2. Exception handling areas to be aware of1) Catch and finally code should be very short, and the success rate is very high, to avoid throwing an exception. Otherwise the CLR terminates the process, avoiding security breaches or unpredictable consequences. This is similar to Windows blue screen, a serious error has occurred, preferring to make the system unusable. 2) Catch block try to avoid directly catching the base class exception of the exception, but should catch the specific exception class.

About exception snapping in C #

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.