GetGenericArguments Method

MethodBase.GetGenericArguments Method

[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]

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

Namespace:  System.Reflection
Assembly:  mscorlib (in mscorlib.dll)

public virtual Type[] GetGenericArguments()

Return Value

Type: System.Type []
An array that contains the type arguments of a generic method or the type parameters of a generic method definition. Returns an empty array if the current method is not a generic method.

ExceptionCondition
NotSupportedException

The current object is a ConstructorInfo. Generic constructors are not supported.

The elements of the returned array are in the order in which they appear in the list of type parameters for the generic method.

  • If the current method is a closed constructed method (that is, the ContainsGenericParameters property returns false), the array returned by the GetGenericArguments method contains the types that have been assigned to the generic type parameters of the generic method definition.

  • If the current method is a generic method definition, the array contains the type parameters.

  • If the current method is an open constructed method (that is, the ContainsGenericParameters property returns true) in which specific types have been assigned to some type parameters and type parameters of enclosing generic types have been assigned to other type parameters, the array contains both types and type parameters. Use the IsGenericParameter property to tell them apart. For a demonstration of this scenario, see the code example provided for the ContainsGenericParameters property.

Generic constructors are not supported. This property throws NotSupportedException if not overridden in a derived class, so an exception is thrown if the current instance is of type ConstructorInfo.

Version Notes

Windows Phone

 GetGenericArguments is present but not supported in Windows Phone.

Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Windows Phone

Show:
© 2017 Microsoft