See a hierarchy of useful exception classes for use in C#

The example Throw standard exceptions in C# explains how to throw exceptions to indicate a problem in a program. Throwing an exception is easiest if you can find an existing exception class that correctly represents your situation. The following list shows a hierarchy of some of the most useful exception classes.

For example, if you want to make a stub or placeholder method to reserve space for code you will add later, you can use the following code to make the method throw the NotImplementedException exception. You can write other code in the program that calls this method and it will compile, but it will fail if you invoke the method at runtime.

throw new NotImplementedException("The SelfDestruct method is not yet implemented.");


What did you think of this article?

  • No trackbacks exist for this post.

Leave a comment

Submitted comments are subject to moderation before being displayed.


 Email (will not be published)


Your comment is 0 characters limited to 3000 characters.