ArgumentTypeGuard.

ThrowIfNotTypeOf<T>(T, Type, string) Method

Summary

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

Syntax

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

Examples

Throws when argument is not type of type.

var localVar = argument.ThrowIfNotTypeOf(nameof(argument), typeof(String));

Type Parameters

Name Description
T

Parameters

Name Type Description
argument T Argument value.
type Type Compare type.
nameOfArgument string Name of the argument.

Return Value

Type Description
T
GitHub