Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

MethodInfo.IsGenericMethod Property

Gets a value indicating whether the current method is a generic method.

Namespace:  System.Reflection
Assembly:  mscorlib (in mscorlib.dll)
public override bool IsGenericMethod { get; }

Property Value

Type: System.Boolean
true if the current method is a generic method; otherwise, false.

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

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

generic method definition

The IsGenericMethodDefinition property is true.

Defines a generic method. A constructed method is created by calling the MakeGenericMethod method on a MethodInfo object that represents a generic method definition, and specifying an array of type arguments.

MakeGenericMethod 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.

The following code example uses the IsGenericMethod property to display a message indicating whether a method is generic.

This example is part of a larger example provided for the MakeGenericMethod method.

Console.WriteLine("\tIs it a generic method? {0}", 
    mi.IsGenericMethod);

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98, Windows CE, Windows Mobile for Smartphone, Windows Mobile for Pocket PC, Xbox 360, Zune

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0

.NET Compact Framework

Supported in: 3.5, 2.0

XNA Framework

Supported in: 3.0, 2.0, 1.0
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.