Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

MethodBase.ContainsGenericParameters Property

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

Namespace:  System.Reflection
Assembly:  mscorlib (in mscorlib.dll)
public virtual bool ContainsGenericParameters { get; }

Property Value

Type: System.Boolean
true if the current MethodBase object represents a generic method that contains unassigned generic type parameters; otherwise, false.

A generic method can be invoked only if there are no generic type definitions or open constructed types in the type arguments of the method itself or in any enclosing types. Because types can be arbitrarily complex, making this recursive determination is difficult. For convenience, and to reduce the chance of error, the ContainsGenericParameters property provides a standard way to distinguish between closed constructed methods, which can be invoked, and open constructed methods, which cannot. If the ContainsGenericParameters property returns true, the method cannot be invoked.

The 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 IsGenericMethod property, which returns false for such a method.

Similarly, the ContainsGenericParameters property parameter returns true for any constructor in an open type, even though constructors cannot have type parameters of their own.

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.

.NET Framework

Supported in: 4.5.1, 4.5, 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Portable Class Library

Supported in: Portable Class Library

.NET for Windows Store apps

Supported in: Windows 8

.NET for Windows Phone apps

Supported in: Windows Phone 8.1, Windows Phone 8, Silverlight 8.1

Windows Phone 8.1, Windows Phone 8, Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Show:
© 2014 Microsoft. All rights reserved.