System.Type.IsGenericParameter Property

Gets a value indicating whether the current Type represents a type parameter in the definition of a generic type or method.

Syntax

public virtual bool IsGenericParameter { get; }

Value

true if the current object represents a type parameter of a generic type or method; otherwise false.

Remarks

Type objects that represent generic type parameters can be obtained by calling the Type.GetGenericArguments method of a Type object that represents a generic type definition, or the System.Reflection.MethodInfo.GetGenericArguments method of a System.Reflection.MethodInfo object that represents a generic method definition.

  • For a generic type or method definition, the Type.IsGenericParameter property returns true for every element of the resulting array.

  • For a closed constructed type or method, the Type.IsGenericParameter property returns false for every element of the array returned by the Type.GetGenericArguments method.

  • For an open constructed type or method, some elements of the array might be specific types and others might be type parameters. Type.IsGenericParameter returns false for the types and true for the type parameters. The code example for the Type.ContainsGenericParameters property demonstrates a generic class with a mixture of types and type parameters.

For a list of the invariant conditions for terms used in generic reflection, see the Type.IsGenericType property remarks.

Example

For an example of using this method, see the example for Type.GenericParameterPosition.

Requirements

Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 2.0.0.0, 4.0.0.0
Since: .NET 2.0