C# MethodInfo GetGenericArguments

Description

MethodInfo GetGenericArguments Returns an array of Type objects that represent the type arguments of a generic method or the type parameters of a generic method definition.

Syntax

MethodInfo.GetGenericArguments has the following syntax.


[ComVisibleAttribute(true)]
public override Type[] GetGenericArguments()

Returns

MethodInfo.GetGenericArguments method returns

Example


/*//  w ww .jav a 2 s .c  o  m
if (mi.IsGenericMethod)
{
    Type[] typeArguments = mi.GetGenericArguments();
    Console.WriteLine(typeArguments.Length);

    foreach (Type tParam in typeArguments)
    {
        if (tParam.IsGenericParameter)
        {
            Console.WriteLine("\t\t{0}  parameter position {1}" +
                "\n\t\t   declaring method: {2}",
                tParam,
                tParam.GenericParameterPosition,
                tParam.DeclaringMethod);
        }
    }
}
*/

The code above generates the following result.





















Home »
  C# Tutorial »
    System.Reflection »




EventInfo
FieldInfo
MemberInfo
MethodInfo
ParameterInfo
TypeInfo