MethodBase.ContainsGenericParameters MethodBase.ContainsGenericParameters MethodBase.ContainsGenericParameters MethodBase.ContainsGenericParameters Property

定义

获取一个值,该值指示泛型方法是否包含未赋值的泛型类型参数。Gets a value indicating whether the generic method contains unassigned generic type parameters.

public:
 virtual property bool ContainsGenericParameters { bool get(); };
public virtual bool ContainsGenericParameters { get; }
member this.ContainsGenericParameters : bool
Public Overridable ReadOnly Property ContainsGenericParameters As Boolean

属性值

如果当前 MethodBase 对象表示的泛型方法包含未赋值的泛型类型参数,则为 true;否则为 falsetrue 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. 为方便起见,若要减少出现错误ContainsGenericParameters的可能性,属性提供了一种标准方法来区分已关闭的构造方法(可以调用)和开放构造方法(不能)。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. 如果属性返回true,则不能调用该方法。 ContainsGenericParametersIf the ContainsGenericParameters property returns true, the method cannot be invoked.

ContainsGenericParameters属性以递归方式搜索类型参数。The ContainsGenericParameters property searches recursively for type parameters. 例如,它为开放true类型A<T>A(Of T)在 Visual Basic 中)中的任何方法返回,即使方法本身不是泛型也是如此。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. 将此与IsGenericMethod属性的行为进行对比,这将false为此类方法返回。Contrast this with the behavior of the IsGenericMethod property, which returns false for such a method.

同样, ContainsGenericParameters即使构造函数不true能具有自己的类型参数,属性参数也会为开放类型中的任何构造函数返回。Similarly, the ContainsGenericParameters property parameter returns true for any constructor in an open type, even though constructors cannot have type parameters of their own.

有关特定于泛型方法的术语的固定条件列表,请参见IsGenericMethod属性。For a list of the invariant conditions for terms specific to generic methods, see the IsGenericMethod property. 有关泛型反射中使用的其他术语的固定条件列表,请参见Type.IsGenericType属性。For a list of the invariant conditions for other terms used in generic reflection, see the Type.IsGenericType property.

适用于

另请参阅