Summary

The .NET Framework uses exceptions to report a variety of errors to .NET applications. The C# language fully supports exception processing and enables you to define your own exceptions in addition to working with the exceptions defined by the .NET Framework. Exceptions can be thrown and caught by C# code. C# code can also catch exceptions thrown by the .NET Framework.

The advantage to using exceptions is that you don't need to check every single method call for an error. You can enclose a group of method calls in a try block, and you can write your code as if every method call in the block were successful. This makes the code in your try block much cleaner, because it does not need any inline error checking. Any exceptions thrown from code in your try block are dealt with in a catch block.

0 0

Post a comment