Title: See a hierarchy of exception classes for use in C#
The example Throw a standard exception 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.
throw new NotImplementedException(
"The SelfDestruct method is not yet implemented.");
Now 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.
|