TypeBuilder.MakeGenericType(Type[]) Metódus
Definíció
Fontos
Egyes információk olyan, kiadás előtti termékekre vonatkoznak, amelyek a kiadásig még jelentősen módosulhatnak. A Microsoft nem vállal kifejezett vagy törvényi garanciát az itt megjelenő információért.
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.
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:
Ha metódusokat, mezőket és konstruktorokat szeretne lekérni ezekhez az általános típusokhoz, használja a , GetMethod(Type, MethodInfo)és GetField(Type, FieldInfo) a GetConstructor(Type, ConstructorInfo)metódus túlterhelését.
Az azonos létrehozott típust képviselő két példány nem egyenlő. A következő kód például a következőt
t1.Equals(t2)adjafalsevissza:
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)