ParameterAttributes Enumeráció

Definíció

Meghatározza a paraméterekhez társítható attribútumokat. Ezek a CorHdr.h-ban vannak definiálva.

Ez a felsorolás támogatja a tagértékek bitenkénti kombinációját.

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
Öröklődés
ParameterAttributes
Attribútumok

Mezők

Name Érték Description
None 0

Azt adja meg, hogy nincs paraméterattribútum.

In 1

Megadja, hogy a paraméter egy bemeneti paraméter.

Out 2

Megadja, hogy a paraméter egy kimeneti paraméter.

Lcid 4

Megadja, hogy a paraméter területi azonosító (lcid).

Retval 8

Megadja, hogy a paraméter visszatérési érték-e.

Optional 16

Megadja, hogy a paraméter nem kötelező.

HasDefault 4096

Megadja, hogy a paraméter alapértelmezett értékkel rendelkezik-e.

HasFieldMarshal 8192

Azt adja meg, hogy a paraméter rendelkezik-e mezőre vonatkozó marsallálási információkkal.

Reserved3 16384

Fenntartott

Reserved4 32768

Fenntartott

ReservedMask 61440

Megadja, hogy a paraméter foglalt-e.

Példák

Az alábbi példa a megadott paraméter attribútumait jeleníti meg.

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

Megjegyzések

Az érték lekéréséhez ParameterAttributes először a Type. TypeA tömb lekérése a ParameterInfo tömbből. Az ParameterAttributes érték a tömbön belül van.

Ezek az enumerátorértékek nem kötelező metaadatoktól függenek. Nem minden attribútum érhető el az összes fordítótól. Tekintse meg a megfelelő fordítói utasításokat annak megállapításához, hogy mely számba vehető értékek érhetők el.

A következőre érvényes: