TypeBuilder.MakeGenericType(Type[]) Méthode

Définition

Remplace les éléments d’un tableau de types pour les paramètres de type de la définition de type générique actuelle et retourne le type construit résultant.

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ètres

typeArguments
Type[]

Tableau de types à remplacer par les paramètres de type de la définition de type générique actuelle.

Retours

Représentant Type le type construit formé en remplaçant les éléments des paramètres de typeArguments type du type du type actuel.

Attributs

Exceptions

Le type actuel ne représente pas la définition d’un type générique. Autrement dit, IsGenericTypeDefinition retourne false.

typeArguments a la valeur null.

- ou -

N’importe quel élément est typeArgumentsnull.

La Module propriété de n’importe quel élément est typeArgumentsnull.

- ou -

La Assembly propriété du module d’un élément de typeArguments l’objet est null.

Remarques

Utilisez cette méthode lorsque votre code émis nécessite un type construit à partir de la définition de type générique actuelle. Il n’est pas nécessaire d’appeler la CreateType méthode avant d’appeler la MakeGenericType méthode sur une TypeBuilder définition de type générique. Si le courant TypeBuilder ne représente pas la définition d’un type générique, il InvalidOperationException est levée.

L’objet retourné par cette méthode fonctionne comme espace réservé pour un type générique construit dans votre code émis. Il s’agit d’une instance d’une classe dérivée d’une Type capacité limitée. En particulier:

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)

S’applique à