Chapter 6 Quick Reference

2 333 0
Chapter 6 Quick Reference

Đang tải... (xem toàn văn)

Thông tin tài liệu

Chapter 6 Quick Reference To Do this Throw an exception Use a throw statement. For example: throw new FormatException(source); Ensure that integer arithmetic is always checked for overflow Use the checked keyword. For example: int number = Int32.MaxValue; checked { number++; } Catch a specific exception Write a catch handler that catches the specific exception class. For example: try { . } catch (FormatException fEx) { . } Catch all exceptions in a single catch handler Write a catch handler that catches Exception. For example: try { . } catch (Exception ex) { . } Ensure that some code will always be run, even if an exception is thrown Write the code inside a finally block. For example: try { . } To Do this finally { // always run } . Chapter 6 Quick Reference To Do this Throw an exception Use a throw statement. For example:

Ngày đăng: 20/10/2013, 15:15

Tài liệu cùng người dùng

  • Đang cập nhật ...

Tài liệu liên quan