Bahasa

TypeBuilder.MakeGenericType(Type[]) Metode

Definisi

Mengganti elemen array jenis untuk parameter jenis definisi jenis generik saat ini, dan mengembalikan jenis yang dibuat yang dihasilkan.

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

Parameter

typeArguments
Type[]

Array jenis yang akan digantikan untuk parameter jenis definisi jenis generik saat ini.

Mengembalikan

Mewakili Type jenis yang dibangun yang dibentuk dengan mengganti elemen typeArguments untuk parameter jenis jenis generik saat ini.

Atribut

Pengecualian

Jenis saat ini tidak mewakili definisi jenis generik. Artinya, IsGenericTypeDefinition mengembalikan false.

typeArguments adalah null.

-atau-

Elemen apa pun adalah typeArgumentsnull.

Properti Module dari elemen typeArguments apa pun adalah null.

-atau-

Properti Assembly modul dari elemen typeArguments apa pun adalah null.

Keterangan

Gunakan metode ini ketika kode yang Anda keluarkan memerlukan jenis yang dibangun dari definisi jenis generik saat ini. Tidak perlu memanggil CreateType metode sebelum memanggil MakeGenericType metode pada TypeBuilder yang mewakili definisi jenis generik. Jika saat ini TypeBuilder tidak mewakili definisi jenis generik, maka InvalidOperationException akan dilemparkan.

Objek yang dikembalikan oleh metode ini berfungsi sebagai tempat penampung untuk jenis generik yang dibangun dalam kode yang Dipancarkan. Ini adalah instans kelas yang berasal dari Type yang memiliki kemampuan terbatas. Secara khusus:

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)

Berlaku untuk