ParameterAttributes Énumération

Définition

Définit les attributs qui peuvent être associés à un paramètre. Celles-ci sont définies dans CorHdr.h.

Cette énumération prend en charge une combinaison au niveau du bit de ses valeurs membres.

public enum class ParameterAttributes
[System.Flags]
public enum ParameterAttributes
[System.Flags]
[System.Serializable]
public enum ParameterAttributes
[System.Flags]
[System.Serializable]
[System.Runtime.InteropServices.ComVisible(true)]
public enum ParameterAttributes
[<System.Flags>]
type ParameterAttributes = 
[<System.Flags>]
[<System.Serializable>]
type ParameterAttributes = 
[<System.Flags>]
[<System.Serializable>]
[<System.Runtime.InteropServices.ComVisible(true)>]
type ParameterAttributes = 
Public Enum ParameterAttributes
Héritage
ParameterAttributes
Attributs

Champs

Nom Valeur Description
None 0

Spécifie qu’il n’existe aucun attribut de paramètre.

In 1

Spécifie que le paramètre est un paramètre d’entrée.

Out 2

Spécifie que le paramètre est un paramètre de sortie.

Lcid 4

Spécifie que le paramètre est un identificateur de paramètres régionaux (lcid).

Retval 8

Spécifie que le paramètre est une valeur de retour.

Optional 16

Spécifie que le paramètre est facultatif.

HasDefault 4096

Spécifie que le paramètre a une valeur par défaut.

HasFieldMarshal 8192

Spécifie que le paramètre a des informations de marshaling de champs.

Reserved3 16384

Réservé.

Reserved4 32768

Réservé.

ReservedMask 61440

Spécifie que le paramètre est réservé.

Exemples

L’exemple suivant affiche les attributs du paramètre spécifié.

using System;
using System.Reflection;

class paramatt
{
    public static void mymethod (string str1, out string str2, ref string str3)
    {
        str2 = "string";
    }

    public static int Main(string[] args)
    {
        Console.WriteLine("\nReflection.ParameterAttributes");

        // Get the Type and the method.

        Type Mytype = Type.GetType("paramatt");
        MethodBase Mymethodbase = Mytype.GetMethod("mymethod");

        // Display the method.
        Console.Write("\nMymethodbase = " + Mymethodbase);

        // Get the ParameterInfo array.
        ParameterInfo[] Myarray = Mymethodbase.GetParameters();

        // Get and display the attributes for the second parameter.
        ParameterAttributes Myparamattributes = Myarray[1].Attributes;

        Console.Write("\nFor the second parameter:\nMyparamattributes = "
            + (int) Myparamattributes
            + ", which is an "
            + Myparamattributes.ToString());

        return 0;
    }
}
Imports System.Reflection

Class paramatt

    Public Shared Sub mymethod(ByVal str1 As String, ByRef str2 As String, _
    ByRef str3 As String)
        str2 = "string"
    End Sub

    Public Shared Function Main() As Integer
        Console.WriteLine(ControlChars.CrLf + "Reflection.ParameterAttributes")

        ' Get the Type and the method.
        Dim Mytype As Type = Type.GetType("paramatt")
        Dim Mymethodbase As MethodBase = Mytype.GetMethod("mymethod")

        ' Display the method.
        Console.WriteLine("Mymethodbase = " + Mymethodbase.ToString())

        ' Get the ParameterInfo array.
        Dim Myarray As ParameterInfo() = Mymethodbase.GetParameters()

        ' Get and display the attributes for the second parameter.
        Dim Myparamattributes As ParameterAttributes = Myarray(1).Attributes

        Console.WriteLine("For the second parameter:" + ControlChars.CrLf _
           + "Myparamattributes = " + CInt(Myparamattributes).ToString() _
           + ", which is a " + Myparamattributes.ToString())

        Return 0
    End Function
End Class

Remarques

Pour obtenir la ParameterAttributes valeur, commencez par obtenir le Type. À partir du Type, obtenez le ParameterInfo tableau. La ParameterAttributes valeur se trouve dans le tableau.

Ces valeurs d’énumérateur dépendent des métadonnées facultatives. Tous les attributs ne sont pas disponibles à partir de tous les compilateurs. Consultez les instructions du compilateur appropriées pour déterminer quelles valeurs énumérées sont disponibles.

S’applique à