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

MethodBase.GetGenericArguments Method

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)

[ComVisibleAttribute(true)] 
public virtual Type[] GetGenericArguments ()
/** @attribute ComVisibleAttribute(true) */ 
public Type[] GetGenericArguments ()
ComVisibleAttribute(true) 
public function GetGenericArguments () : Type[]
Not applicable.

Return Value

An array of Type objects that represent 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.
Exception typeCondition

NotSupportedException

The current object is a ConstructorInfo. Generic constructors are not supported in the .NET Framework version 2.0. This exception is the default behavior if this method is not overridden in a derived class.

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 in the .NET Framework version 2.0. This property throws NotSupportedException if not overridden in a derived class, so an exception is thrown if the current instance is of type ConstructorInfo.

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.

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0

.NET Compact Framework

Supported in: 2.0

XNA Framework

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

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.