Επεξεργασία

Κοινή χρήση μέσω


MethodBase.IsGenericMethod Property

Definition

Gets a value indicating whether the method is generic.

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

Property Value

true if the current MethodBase represents a generic method; otherwise, false.

Remarks

Use the IsGenericMethod property to determine whether the current MethodBase object represents a generic method. Use the ContainsGenericParameters property to determine whether the current MethodBase object represents an open constructed method or a closed constructed method.

Note

Generics are not supported by default; this property returns false if not overridden in a derived class. Generic constructors are not supported in the .NET Framework version 2.0, so this property returns false if the current instance is of type ConstructorInfo.

The following table summarizes the invariant conditions for terms specific to generic methods. For other terms used in generic reflection, such as generic type parameter and generic type, see the Type.IsGenericType property.

Term Invariant condition
generic method definition The IsGenericMethodDefinition property is true.
Defines a generic method. A constructed method is created by calling the MethodInfo.MakeGenericMethod method on a MethodInfo object that represents a generic method definition, and specifying an array of type arguments.
The MakeGenericMethod method can be called only on generic method definitions.
Any generic method definition is a generic method, but the converse is not true.
generic method The IsGenericMethod property is true.
Can be a generic method definition, an open constructed method, or a closed constructed method.
open constructed method The ContainsGenericParameters property is true.
It is not possible to invoke an open constructed method.
closed constructed method The ContainsGenericParameters property is false.
When examined recursively, the method has no unassigned generic parameters. The containing type has no generic type parameters, and none of the type arguments have generic type parameters.
The method can be invoked.

Applies to

See also