Nyelv

TypeBuilder.MakeGenericType(Type[]) Metódus

Definíció

Egy típustömb elemeit helyettesíti az aktuális általános típusdefiníció típusparamétereihez, és visszaadja az eredményül kapott létrehozott típust.

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

Paraméterek

typeArguments
Type[]

Az aktuális általános típusdefiníció típusparaméterei helyett helyettesítendő típusok tömbje.

Válaszok

Az Type aktuális általános típus típusparamétereinek typeArguments elemeinek helyettesítésével létrehozott létrehozott típust jelképező típus.

Attribútumok

Kivételek

Az aktuális típus nem egy általános típus definícióját jelöli. Vagyis IsGenericTypeDefinition visszaadja false.

typeArguments az null.

-vagy-

Az elem bármely elemetypeArguments.null

Bármely Module elem tulajdonsága typeArguments az null.

-vagy-

A Assembly modul bármely elemének tulajdonsága typeArguments az null.

Megjegyzések

Ezt a módszert akkor használja, ha a kibocsátott kódhoz az aktuális általános típusdefinícióból létrehozott típus szükséges. Nem szükséges meghívni a metódust, CreateType mielőtt egy MakeGenericType általános típusdefiníciót képviselő metódust TypeBuilder hívna meg. Ha az áram TypeBuilder nem egy általános típus definícióját jelöli, akkor a rendszer eldob egy InvalidOperationException értéket.

A metódus által visszaadott objektum helyőrzőként működik a kibocsátott kódban létrehozott általános típushoz. Ez egy olyan osztály példánya, amely korlátozott Type képességekkel rendelkezik. Főleg:

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)

A következőre érvényes: