Gets a value that indicates whether the current stem.Reflection.MethodInfo represents the definition of a generic method.
true if the System.Reflection.MethodInfo object represents the definition of a generic method; otherwise false.
If the current Reflection.MethodInfo represents a generic method definition, then:
- MethodInfo.IsGenericMethodDefinition returns true.
- For each Type object in the array returned by the MethodInfo.GetGenericArguments method: The Type.IsGenericParameter property returns true; the Type.DeclaringMethod returns the current System.Reflection.MethodInfo; the Type.GenericParameterPosition property is the same as the position of the Type object in the array.
Use the MethodInfo.IsGenericMethodDefinition property to determine whether type arguments have been assigned to the type parameters of a generic method. If type arguments have been assigned, the MethodInfo.IsGenericMethodDefinition property returns false even if some of the type arguments are Type objects that represent type parameters of enclosing types. For example, consider the following C# code:
Example
class C { T N<T,U>(T t, U u) {...} public V M<V>(V v) { return N<V,int>(v, 42); } }The method body of M contains a call to method N, specifying the type parameter of M and the type int. The MethodInfo.IsGenericMethodDefinition property returns false for method N<V,int>.
Note:Although the open constructed method N<V,int> is not encountered when reflecting over class C, it must be generated using MethodInfo.MakeGenericMethod(Type[])(System.Type[]).
If a generic method definition includes generic parameters of the declaring type, there will be a generic method definition specific to each constructed type. For example, consider the following C# code:
Example
class B<U,V> {} class C<T> { B<T,S> M<S>() {}}In the constructed type C<int>, the generic method M returns B<int, S>. In the open type C<T>, M returns B<T, S>. In both cases, the MethodInfo.IsGenericMethodDefinition property returns true for the System.Reflection.MethodInfo that represents M.
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.
Note:See the System.Reflection.MethodInfo type for an example of the use of this property.
Operation
This property is read-only.
Namespace: System.Reflection
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 2.0.0.0
Since: .NET 2.0