System.Reflection.MethodInfo.ContainsGenericParameters Property

Gets a value indicating whether a generic method contains unassigned generic type parameters.

Syntax

public override bool ContainsGenericParameters { get; }

Value

true if the System.Reflection.MethodInfo contains unassigned generic type parameters; otherwise false.

Remarks

To invoke a generic method, there must be no generic type definitions or open constructed types in the type arguments of the method itself, or in any enclosing types. Making this recursive determination can be difficult. For convenience, and to reduce the chance of error, the MethodInfo.ContainsGenericParameters property provides a standard way to distinguish between closed constructed methods, which can be invoked, and open constructed methods, which cannot. If the MethodInfo.ContainsGenericParameters property returns true, the method cannot be invoked.

The MethodInfo.ContainsGenericParameters property searches recursively for type parameters. For example, it returns true for any method in an open type A<T> (A(Of T) in Visual Basic), even though the method itself is not generic. Contrast this with the behavior of the MethodInfo.IsGenericMethod property, which returns false for such a method.

For a list of the invariant conditions for terms specific to generic methods, see the MethodInfo.IsGenericMethod property. For a list of the invariant conditions for other terms used in generic reflection, see the Type.IsGenericType property.

Requirements

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