Chương 6 Quick Reference Để Throw một ngoại lệ Làm điều này sử dụng một ném tuyên bố. Ví dụ: ném FormatException mới (nguồn); Sử dụng các từ khoá kiểm tra. | Chapter 6 Quick Reference To Do this Use a throw statement. For example Throw an exception throw new FormatException source Use the checked keyword. For example Ensure that integer arithmetic is always checked for overflow int number checked number Write a catch handler that catches the specific exception class. For example try Catch a specific exception . catch FormatException fEx . Write a catch handler that catches Exception. For example try Catch all exceptions in a single catch handler . catch Exception ex . Write the code inside a finally block. For example Ensure that some code will always be run even if an exception is thrown try . To Do this finally always run