Jazyk

TypeBuilder.MakeGenericType(Type[]) Metoda

Definice

Nahradí prvky pole typů parametry typu aktuální definice obecného typu a vrátí výsledný konstruovaný typ.

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

Parametry

typeArguments
Type[]

Pole typů, které se mají nahradit parametry typu aktuální definice obecného typu.

Návraty

A Type představující konstruovaný typ vytvořený nahrazením prvků typeArguments parametrů typu aktuálního obecného typu.

Atributy

Výjimky

Aktuální typ nepředstavuje definici obecného typu. To znamená, IsGenericTypeDefinition že vrátí false.

typeArguments je null.

nebo

Jakýkoli prvek typeArguments je null.

Vlastnost Module libovolného prvku typeArguments je null.

nebo

Vlastnost Assembly modulu libovolného typeArguments prvku je null.

Poznámky

Tuto metodu použijte, když vygenerovaný kód vyžaduje typ vytvořený z aktuální definice obecného typu. Před voláním CreateType metody na definici MakeGenericType obecného typu není nutné volat TypeBuilder metodu. Pokud aktuální TypeBuilder nepředstavuje definici obecného typu, vyvolá se vyvolán InvalidOperationException .

Objekt vrácený touto metodou funguje jako zástupný symbol pro vytvořený obecný typ v generovaném kódu. Jedná se o instanci třídy odvozené z Type toho, která má omezené možnosti. Zejména jde o toto:

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)

Platí pro