Section 12.9. Wrap-Up


12.9. Wrap-Up

In this chapter, you learned how to use exception handling to deal with errors in an application. We showed how exception handling enables you to remove error-handling code from the "main line" of the program's execution. You saw exception handling in the context of a divide-by-zero example. You learned how to use try blocks to enclose code that may throw an exception, and how to use Catch blocks to deal with exceptions that may arise. We discussed the termination model of exception handling, in which after an exception is handled, program control does not return to the throw point. We also discussed several important classes of the .NET Exception hierarchy, including ApplicationException (from which user-defined exception classes are derived) and SystemException. You learned how to use the Finally block to release resources whether or not an exception occurs, and how to throw and rethrow exceptions with the Throw statement. We also discussed how the Using statement can be used to automate the process of releasing a resource. You then learned how to obtain information about an exception using Exception properties Message, StackTrace and InnerException, and method ToString. You learned how to create your own exception classes. In the next two chapters, we present an in-depth treatment of graphical user interfaces. In these chapters and throughout the rest of the book, we use exception handling to make our examples more robust.



Visual BasicR 2005 for Programmers. DeitelR Developer Series
Visual Basic 2005 for Programmers (2nd Edition)
ISBN: 013225140X
EAN: 2147483647
Year: 2004
Pages: 435

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net