MethodInfo.ContainsGenericParameters 属性

定义

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

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

属性值

Boolean

true 如果当前 MethodInfo 包含未分配的泛型类型参数,则为; 否则为 falsetrue if the current MethodInfo contains unassigned generic type parameters; otherwise, false.

注解

若要调用泛型方法,在方法本身的类型参数中或在任何封闭类型中都不能有泛型类型定义或开放式构造类型。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. 为方便起见,若要减少出现错误的可能性, 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. 如果 ContainsGenericParameters 属性返回 true ,则不能调用该方法。If the ContainsGenericParameters property returns true, the method cannot be invoked.

ContainsGenericParameters属性以递归方式搜索类型参数。The ContainsGenericParameters property searches recursively for type parameters. 例如,它 true 为开放类型中的任何方法返回 A<T> ,即使方法本身不是泛型也是如此。For example, it returns true for any method in an open type A<T>, 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.

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

适用于