Chapter 14. Exceptions

Exceptions are the way that errors are handled in C#. If you have used C++ or Java, you will already be familiar with the idea of exceptions. In C#, all exceptions are runtime exceptions, meaning that methods do not have to declare the exceptions they will throw (for example, there is no equivalent to the Java throws keyword in method definitions). This can take a while to get used to, not least because any method you call can throw any kind of exception. Careful testing and a considered approach to handling runtime exceptions are essential in C# programs. In this chapter, I'll show you how to handle exceptions, throw exceptions, create custom exceptions, and aggregate multiple exceptions. Table 14-1 provides the summary ...

Get Introducing Visual C# 2010 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.