C # managing exceptions and Errors

Source: Internet
Author: User

C # managing Exceptions and Errors

1,try/catch to catch the exception of the statement block, where try{} is written may be error program code,catch{} Is the code that throws the exception , and there can be multiple catchafter a try .

2, the exception is organized by inheritance hierarchy, the exception belongs to a family named systemexception(System exception), and systemexception belongs to Exception(abnormal) family.

3. What happens if an exception matches the multiple catch handlers at the end of the try block ?

Note: After an exception occurs, the first matching exception handler that is discovered by the runtime is run and other handlers are ignored. Therefore, after a try block, the more specific catch handler should be placed before the regular catch handler.

4, If the current value is already the maximum value of int 2147483647 plus 1, what will be the result?

By default, you will get an incorrect answer that overflows to the maximum negative value of -2147483647. Because integer operations are a common operation, overflow checking of each integer expression can result in severe performance degradation and, of course, the ability to enable overflow checking on its own.

5 checked unchecked keyword, checked unchecked force not to check all integer operations in the statement block, never throw an exception.

6.to ensure that a statement always runs, put it in a finally block. the finally block is either advanced after the try block, or the last catch after the try Block After. The finally block will always run whenever the program enters a try block associated with a finally block .

C # managing exceptions and Errors

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.