C#-vs Exception Handling

Source: Internet
Author: User
VS Exception handling
  • Conventional
The try may produce an exception to the code, when a row produces an exception, the line below the code does not execute, go to the catch to start the catch (System. Exception e) e.message e.finally can be executed without this paragraph having an exception. such as turning off data connections.
  • Can be handled according to the type of exception, such as 0 divided by a number, array out of bounds.
From top to bottom, find the kind that the current exception belongs to, Try{}catch (system.0 divided by the exception class name E) {}catch (System. Array out of bounds e) {}catch (System.Exception e) {}
  • Delivery of exceptions
If there is no corresponding type, the exception is transferred to the calling statement, no exception is handled, to the CLR, the CLR throws a unhandled exception in addition to the class library, or the exception that needs to be handled together, the exception is generally handled by the code snippet that may produce the exception. Nested try, which can be passed to an external call and passed to the calling statement
  • You can throw an exception yourself, for
Exception myexception = new Exception ("message"); throw myexception;
  • Customizable exceptions, inherited from System.application.exception

Class MyException (String Message): system.application.exception

{ }
  • vs Set breakpoints When debugging, you can also view variables and objects.
Ablabla can look at the current line and the previous row used Lblabla can see in the life cycle of Watch can be seen in the life cycle, manual selection of concern, because in the life cycle of the possible many.

C#-vs Exception Handling

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.