TypeBuilder.MakeGenericType(Type[]) Método

Definição

Substitui os elementos de um array de tipos pelos parâmetros de tipo da definição genérica atual e devolve o tipo construído resultante.

public:
 override Type ^ MakeGenericType(... cli::array <Type ^> ^ typeArguments);
[System.Diagnostics.CodeAnalysis.RequiresDynamicCode("The native code for this instantiation might not be available at runtime.")]
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("If some of the generic arguments are annotated (either with DynamicallyAccessedMembersAttribute, or generic constraints), trimming can't validate that the requirements of those annotations are met.")]
public override Type MakeGenericType(params Type[] typeArguments);
public override Type MakeGenericType(params Type[] typeArguments);
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("If some of the generic arguments are annotated (either with DynamicallyAccessedMembersAttribute, or generic constraints), trimming can't validate that the requirements of those annotations are met.")]
public override Type MakeGenericType(params Type[] typeArguments);
[<System.Diagnostics.CodeAnalysis.RequiresDynamicCode("The native code for this instantiation might not be available at runtime.")>]
[<System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("If some of the generic arguments are annotated (either with DynamicallyAccessedMembersAttribute, or generic constraints), trimming can't validate that the requirements of those annotations are met.")>]
override this.MakeGenericType : Type[] -> Type
override this.MakeGenericType : Type[] -> Type
[<System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("If some of the generic arguments are annotated (either with DynamicallyAccessedMembersAttribute, or generic constraints), trimming can't validate that the requirements of those annotations are met.")>]
override this.MakeGenericType : Type[] -> Type
Public Overrides Function MakeGenericType (ParamArray typeArguments As Type()) As Type

Parâmetros

typeArguments
Type[]

Um array de tipos a substituir os parâmetros de tipo da definição genérica atual do tipo.

Devoluções

A Type representa o tipo construído formado substituindo os elementos de typeArguments pelos parâmetros do tipo genérico atual.

Atributos

Exceções

O tipo atual não representa a definição de um tipo genérico. Ou seja, IsGenericTypeDefinition retorna false.

typeArguments é null.

-ou-

Qualquer elemento de typeArguments é null.

A Module propriedade de qualquer elemento de typeArguments é null.

-ou-

A Assembly propriedade do módulo de qualquer elemento de typeArguments é null.

Observações

Use este método quando o seu código emitido requer um tipo construído a partir da definição de tipo genérica atual. Não é necessário chamar o CreateType método antes de chamar o MakeGenericType método em um TypeBuilder que representa uma definição genérica de tipo. Se a corrente TypeBuilder não representar a definição de um tipo genérico, um InvalidOperationException é lançado.

O objeto devolvido por este método funciona como um marcador de lugar para um tipo genérico construído no seu código emitido. É uma instância de uma classe derivada de Type que tem capacidades limitadas. Em particular:

Type t1 = tbldr.MakeGenericType(typeof(string));
Type t2 = tbldr.MakeGenericType(typeof(string));
bool result = t1.Equals(t2);
Dim t1 As Type = tbldr.MakeGenericType(GetType(String))
Dim t2 As Type = tbldr.MakeGenericType(GetType(String))
Dim result As Boolean = t1.Equals(t2)

Aplica-se a