ParameterAttributes 列挙型
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
パラメーターに関連付けることができる属性を定義します。 これらは CorHdr.h で定義されています。
この列挙体は、メンバー値のビットごとの組み合わせをサポートしています。
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
- 継承
- 属性
フィールド
| 名前 | 値 | 説明 |
|---|---|---|
| None | 0 | パラメーター属性がないことを指定します。 |
| In | 1 | パラメーターが入力パラメーターであることを指定します。 |
| Out | 2 | パラメーターが出力パラメーターであることを指定します。 |
| Lcid | 4 | パラメーターがロケール識別子 (lcid) であることを指定します。 |
| Retval | 8 | パラメーターが戻り値であることを指定します。 |
| Optional | 16 | パラメーターが省略可能であることを指定します。 |
| HasDefault | 4096 | パラメーターに既定値があることを指定します。 |
| HasFieldMarshal | 8192 | パラメーターにフィールド マーシャリング情報があることを指定します。 |
| Reserved3 | 16384 | 予約済み。 |
| Reserved4 | 32768 | 予約済み。 |
| ReservedMask | 61440 | パラメーターが予約されていることを指定します。 |
例
次の例では、指定したパラメーターの属性を表示します。
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
注釈
ParameterAttributes値を取得するには、最初にTypeを取得します。
Typeから、ParameterInfo配列を取得します。
ParameterAttributes値は配列内にあります。
これらの列挙子の値は、省略可能なメタデータに依存します。 すべてのコンパイラからすべての属性を使用できるわけではありません。 使用可能な列挙値を判断するには、適切なコンパイラ命令を参照してください。