英語で読む

次の方法で共有


ParameterAttributes 列挙型

定義

パラメーターに関連付けることができる属性を定義します。 これらは、CorHdr.h で定義されます。

この列挙体は、メンバー値のビットごとの組み合わせをサポートしています。

C#
[System.Flags]
public enum ParameterAttributes
C#
[System.Flags]
[System.Serializable]
public enum ParameterAttributes
C#
[System.Flags]
[System.Serializable]
[System.Runtime.InteropServices.ComVisible(true)]
public enum ParameterAttributes
継承
ParameterAttributes
属性

フィールド

名前 説明
HasDefault 4096

パラメーターが既定の値を使用することを指定します。

HasFieldMarshal 8192

パラメーターがフィールド マーシャリング情報を持つことを指定します。

In 1

パラメーターが入力パラメーターであることを指定します。

Lcid 4

パラメーターがロケール識別子 (LCID: LoCale Identifier) であることを指定します。

None 0

パラメーター属性がないことを指定します。

Optional 16

パラメーターが省略可能であることを指定します。

Out 2

パラメーターが出力パラメーターであることを指定します。

Reserved3 16384

予約済み。

Reserved4 32768

予約済み。

ReservedMask 61440

パラメーターが予約済みであることを指定します。

Retval 8

パラメーターが戻り値を持つことを指定します。

次の例では、指定したパラメーターの属性を表示します。

C#
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;
    }
}

注釈

値を取得するには、最初に ParameterAttributes を取得します Type。 から、 Type配列を取得します ParameterInfo 。 値は ParameterAttributes 配列内にあります。

これらの列挙子の値は、省略可能なメタデータに依存します。 すべてのコンパイラからすべての属性を使用できるわけではありません。 使用できる列挙値を決定するには、適切なコンパイラの手順を参照してください。

適用対象

製品 バージョン
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 1.0, 1.1, 1.2, 1.3, 1.4, 1.6, 2.0, 2.1
UWP 10.0