ParameterAttributes Enum

Definisi

Menentukan atribut yang dapat dikaitkan dengan parameter. Ini didefinisikan dalam CorHdr.h.

Enumerasi ini mendukung kombinasi bitwise dari nilai yang termasuk di dalamnya.

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
Warisan
ParameterAttributes
Atribut

Bidang

Nama Nilai Deskripsi
None 0

Menentukan bahwa tidak ada atribut parameter.

In 1

Menentukan bahwa parameter adalah parameter input.

Out 2

Menentukan bahwa parameter adalah parameter output.

Lcid 4

Menentukan bahwa parameter adalah pengidentifikasi lokal (lcid).

Retval 8

Menentukan bahwa parameter adalah nilai pengembalian.

Optional 16

Menentukan bahwa parameter bersifat opsional.

HasDefault 4096

Menentukan bahwa parameter memiliki nilai default.

HasFieldMarshal 8192

Menentukan bahwa parameter memiliki informasi marshaling bidang.

Reserved3 16384

Direservasi.

Reserved4 32768

Direservasi.

ReservedMask 61440

Menentukan bahwa parameter dicadangkan.

Contoh

Contoh berikut menampilkan atribut parameter yang ditentukan.

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

Keterangan

Untuk mendapatkan nilainya ParameterAttributes , pertama-tama Typedapatkan . TypeDari , dapatkan ParameterInfo array. Nilai ParameterAttributes berada dalam array.

Nilai enumerator ini bergantung pada metadata opsional. Tidak semua atribut tersedia dari semua pengkompilasi. Lihat instruksi pengkompilasi yang sesuai untuk menentukan nilai enumerasi mana yang tersedia.

Berlaku untuk