Chapter 4. Exceptions

Exceptions are .NET’s primary mechanism for communicating error conditions. Exceptions have great power, but with great power comes great responsibility. Like anything, exceptions can be abused, but that is no excuse to underuse them.

Compared to returning error codes, exceptions offer numerous advantages, such as being able to jump up many frames in a call stack and including as much information as you want.

Throw an Exception

Get C# 4.0 How-To now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.