The C# Programming Language, Third Edition
by Anders Hejlsberg, Mads Torgersen, Scott Wiltamuth, Peter Golde
16. Exceptions
Exceptions in C# provide a structured, uniform, and type-safe way of handling both system-level and application-level error conditions. The exception mechanism in C# is quite similar to that of C++, with a few important differences:
• In C#, all exceptions must be represented by an instance of a class type derived from System.Exception. In C++, any value of any type can be used to represent an exception.
• In C#, a finally block (§8.10) can be used to write termination code that executes in both normal execution and exceptional conditions. Such code is difficult to write in C++ without duplicating code.
• In C#, system-level exceptions such as overflow, divide-by-zero, and null dereferences have well-defined exception classes ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access