MethodBase.GetGenericArguments Método
Definição
public:
virtual cli::array <Type ^> ^ GetGenericArguments();
public virtual Type[] GetGenericArguments ();
[System.Runtime.InteropServices.ComVisible(true)]
public virtual Type[] GetGenericArguments ();
abstract member GetGenericArguments : unit -> Type[]
override this.GetGenericArguments : unit -> Type[]
[<System.Runtime.InteropServices.ComVisible(true)>]
abstract member GetGenericArguments : unit -> Type[]
override this.GetGenericArguments : unit -> Type[]
Public Overridable Function GetGenericArguments () As Type()
Retornos
- Type[]
Uma matriz de objetos Type que representam os argumentos de tipo de um método genérico ou os parâmetros de tipo de uma definição de método genérico.An array of Type objects that represent the type arguments of a generic method or the type parameters of a generic method definition. Retornará uma matriz vazia se o método atual não for um método genérico.Returns an empty array if the current method is not a generic method.
- Atributos
Exceções
O objeto atual é um ConstructorInfo.The current object is a ConstructorInfo. Não há suporte para construtores genéricos no .NET Framework versão 2.0.Generic constructors are not supported in the .NET Framework version 2.0. Essa exceção será o comportamento padrão se esse método não for substituído em uma classe derivada.This exception is the default behavior if this method is not overridden in a derived class.
Comentários
Os elementos da matriz retornada estão na ordem em que aparecem na lista de parâmetros de tipo para o método genérico.The elements of the returned array are in the order in which they appear in the list of type parameters for the generic method.
Se o método atual for um método construído fechado (ou seja, a ContainsGenericParameters Propriedade retornar
false), a matriz retornada pelo GetGenericArguments método conterá os tipos que foram atribuídos aos parâmetros de tipo genérico da definição do método genérico.If the current method is a closed constructed method (that is, the ContainsGenericParameters property returnsfalse), the array returned by the GetGenericArguments method contains the types that have been assigned to the generic type parameters of the generic method definition.Se o método atual for uma definição de método genérico, a matriz conterá os parâmetros de tipo.If the current method is a generic method definition, the array contains the type parameters.
Se o método atual for um método construído aberto (ou seja, a ContainsGenericParameters propriedade retorna
true) na qual os tipos específicos foram atribuídos a alguns parâmetros de tipo e os parâmetros de tipo dos tipos genéricos delimitadores foram atribuídos a outros parâmetros de tipo, a matriz conterá os tipos e os parâmetros de tipo.If the current method is an open constructed method (that is, the ContainsGenericParameters property returnstrue) 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 a IsGenericParameter propriedade para diferenciá-las.Use the IsGenericParameter property to tell them apart. Para ver uma demonstração desse cenário, consulte o exemplo de código fornecido para a ContainsGenericParameters propriedade.For a demonstration of this scenario, see the code example provided for the ContainsGenericParameters property.
Não há suporte para construtores genéricos no .NET Framework versão 2.0.Generic constructors are not supported in the .NET Framework version 2.0. Essa propriedade gera NotSupportedException se não for substituída em uma classe derivada, portanto, uma exceção será gerada se a instância atual for do tipo ConstructorInfo .This property throws NotSupportedException if not overridden in a derived class, so an exception is thrown if the current instance is of type ConstructorInfo.
Para obter uma lista das condições invariáveis para termos específicos para métodos genéricos, consulte a IsGenericMethod propriedade.For a list of the invariant conditions for terms specific to generic methods, see the IsGenericMethod property. Para obter uma lista das condições invariáveis para outros termos usados em reflexão genérica, consulte a Type.IsGenericType propriedade.For a list of the invariant conditions for other terms used in generic reflection, see the Type.IsGenericType property.