ObjectDisposedExceptionExtensions Class
Provides ThrowNew extension methods for ObjectDisposedException.
public static class ObjectDisposedExceptionExtensionsRemarks
Each public constructor of the exception type has two methods, with the parameters of the constructor. Call them on the exception type, as in ObjectDisposedException.ThrowNew(objectName).
The first method returns no value. Call it as a statement.
The second method has a type parameter, which is also its return type. Call it where the code needs an expression of that type.
See also
Methods
| Name | Description |
|---|---|
| ObjectDisposedException.ThrowNew(string?) | Throws a new ObjectDisposedException. |
| ObjectDisposedException.ThrowNew(string?, Exception?) | Throws a new ObjectDisposedException. |
| ObjectDisposedException.ThrowNew(string?, string?) | Throws a new ObjectDisposedException. |
| ObjectDisposedException.ThrowNew<T>(string?) | Throws a new ObjectDisposedException, where the code needs an expression of type T. |
| ObjectDisposedException.ThrowNew<T>(string?, Exception?) | Throws a new ObjectDisposedException, where the code needs an expression of type T. |
| ObjectDisposedException.ThrowNew<T>(string?, string?) | Throws a new ObjectDisposedException, where the code needs an expression of type T. |
ObjectDisposedException.ThrowNew overloads
ObjectDisposedException.ThrowNew(string?)
Throws a new ObjectDisposedException.
extension(ObjectDisposedException)
{
public static void ThrowNew(string? objectName)
}Parameters
objectNamestring?- A string containing the name of the disposed object.
ObjectDisposedException.ThrowNew(string?, Exception?)
Throws a new ObjectDisposedException.
extension(ObjectDisposedException)
{
public static void ThrowNew(string? message, Exception? innerException)
}Parameters
messagestring?- The error message that explains the reason for the exception.
innerExceptionException?- The exception that is the cause of the current exception. If
innerExceptionis notnull, the current exception is raised in acatchblock that handles the inner exception.
ObjectDisposedException.ThrowNew(string?, string?)
Throws a new ObjectDisposedException.
extension(ObjectDisposedException)
{
public static void ThrowNew(string? objectName, string? message)
}ObjectDisposedException.ThrowNew<T>(string?)
Throws a new ObjectDisposedException, where the code needs an expression of type T.
extension(ObjectDisposedException)
{
public static T ThrowNew<T>(string? objectName)
}Type parameters
T- The type of the expression.
Parameters
objectNamestring?- A string containing the name of the disposed object.
Returns
T This method does not return.
ObjectDisposedException.ThrowNew<T>(string?, Exception?)
Throws a new ObjectDisposedException, where the code needs an expression of type T.
extension(ObjectDisposedException)
{
public static T ThrowNew<T>(string? message, Exception? innerException)
}Type parameters
T- The type of the expression.
Parameters
messagestring?- The error message that explains the reason for the exception.
innerExceptionException?- The exception that is the cause of the current exception. If
innerExceptionis notnull, the current exception is raised in acatchblock that handles the inner exception.
Returns
T This method does not return.
ObjectDisposedException.ThrowNew<T>(string?, string?)
Throws a new ObjectDisposedException, where the code needs an expression of type T.
extension(ObjectDisposedException)
{
public static T ThrowNew<T>(string? objectName, string? message)
}