Common Exception Types
The following exception types are used widely throughout the CLR and .NET Framework. You can throw these yourself or use them as base classes for deriving
custom exception types.
Class | Description |
---|---|
System.ArgumentException |
Thrown when a function is called with a bogus argument. This generally indicates a program bug. |
System.ArgumentNullException |
Subclass of ArgumentException that’s thrown when a function argument is (unexpectedly) . |
System.ArgumentOutOfRangeException |
Subclass of ArgumentException that’s thrown when a (usually numeric) argument is too big or too small. For example, this is thrown when passing a negative number into a function that accepts only positive values. |
System.InvalidOperationException |
Thrown when the state of an object is unsuitable for a method to successfully execute, regardless of any particular argument values. Examples include reading an unopened file or getting the next element from an enumerator where the underlying list has been modified partway through the iteration. |
System.NotSupportedException |
Thrown to indicate that a particular functionality is not supported. A good example is calling the Add method on a collection for which IsReadOnly
returns true .
|
System.NotImplementedException |
Thrown to indicate that a function has not yet been implemented. |
System.ObjectDisposedException |
Thrown when the object upon which the function is called has been disposed. |
System.NullReferenceException |
Thrown when attempting to access a member of an object whose value is null (indicating a bug in your code). |
0 comments:
Post a Comment