次の方法で共有


MethodBase.ContainsGenericParameters Property

Microsoft Silverlight will reach end of support after October 2021. Learn more.

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

Namespace:  System.Reflection
Assembly:  mscorlib (in mscorlib.dll)

Syntax

'Declaration
Public Overridable ReadOnly Property ContainsGenericParameters As Boolean
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.

Remarks

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.

NoteNote:

Generic constructors are not supported, so this property returns false if the current instance is of type ConstructorInfo.

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.

Version Information

Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

XNA Framework

Supported in: Xbox 360, Windows Phone OS 7.0

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.