TAILIEUCHUNG - Apress Introducing Dot Net 4 With Visual Studio_3

Tham khảo tài liệu 'apress introducing dot net 4 with visual studio_3', công nghệ thông tin, hệ điều hành phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | CHAPTER 7 EXCEPTION HANDLING AND SECEPTION SAFETY public EmployeeVerificationException Cause reason String msg Exception inner base msg inner reason protected EmployeeVerificationException SerializationInfo info StreamingContext context base info context public Cause Reason get private set In the method you can see the simple call to Validate on the emp object. This is a rather crude example where you force the validation to fail by throwing an EmployeeVerificationException. But the main focus of the example is the creation of the new exception type. Many times you ll find that just creating a new exception type is good enough to convey the extra information you need to convey. In this case I wanted to illustrate an example where the exception type carries more information about the validation failure so I created a Reason property whose backing field must be initialized in the constructor. Also notice that EmployeeVerificationException derives from . At one point the school of thought was that all .NET Framework-defined exception types would derive from while all user-defined exceptions would derive from ApplicationException thus making it easier to tell the two apart. This goal has been lost partly due to the fact that some .NET Framework-defined exception types derive from ApplicationException. 7 You may be wondering why I defined four exception constructors for this simple exception type. The traditional idiom when defining new exception types is to define the same four public constructors that exposes. Had I decided not to carry the extra reason data then the EmployeeVerificationException constructors would have matched the constructors exactly in their form. If you follow this idiom when defining your own exception types users will be able to treat your new exception type in the same way as other system-defined exceptions. Plus your derived exception will be .

TỪ KHÓA LIÊN QUAN
TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.