. NET exception and Exception Handling

Source: Internet
Author: User

. NET exception and Exception Handling
The parent class of exceptions in. NET (Exception). net is Exception, and most exceptions are generally inherited from Exception. You can customize the Exception class by writing a class that inherits the Exception! Exception Handling Mechanism Try {code that may cause exceptions} code other than Try catch (Exception e) {} finally {} the above Code is described as follows 1. in exception handling, once a problem occurs in try, the program will discard the subsequent code of the exception and directly jump to catch. After running the code in catch, continue to execute code other than Try. 2. the ee parameter in catch () is an exception class object and can be named at will. It is not necessarily called e. 3. Only the code in one try can throw one exception. Why? This is because an exception is thrown and will not be executed later! 4. you can use e. message to obtain exception information 5. finally must be executed. 6. you can use try catch or try finally to handle exceptions. do not escape the problem. Do not just catch the exception and do nothing, or simply print it. This is not an excellent "Exception Handling" style. If you do not know how to handle exceptions, do not catch them. Expose it. If an exception occurs, the problem must be solved. It is not a solution to escape the problem. Especially in hierarchical projects. This will cause the program to be in a deep logical chaos. The problem is hidden, and you don't even know where the problem has occurred. 2. What should I do if I really encounter a programmer with a try or catch? Vs is very powerful. It thinks of this situation. Click debug> exception to enter such a tool and select the triggering option for the second line.

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.