ArgumentTypeGuard.

ThrowIfNotTypeOf<T>(object, string) Method

Summary

Throws an System.InvalidOperationException if argument is not type of T.
Namespace
oehen.arguard
Containing Type
ArgumentTypeGuard

Syntax

public static T ThrowIfNotTypeOf<T>(this object argument, string nameOfArgument)

Examples

Throws when argument is not type of T.

var localVar = argument.ThrowIfNotTypeOf<T>(nameof(argument));

Type Parameters

Name Description
T Expected argument type.

Parameters

Name Type Description
argument object Argument value.
nameOfArgument string Name of the argument.

Return Value

Type Description
T
GitHub