ParameterAttributes 列挙体
パラメータに関連付けることができる属性を定義します。これらの属性は CorHdr.h で定義されています。
この列挙体には、メンバ値をビットごとに演算するための FlagsAttribute 属性が含まれています。
<Flags>
<Serializable>
Public Enum ParameterAttributes
[C#]
[Flags]
[Serializable]
public enum ParameterAttributes
[C++]
[Flags]
[Serializable]
__value public enum ParameterAttributes
[JScript]
public
Flags
Serializable
enum ParameterAttributes
解説
ParameterAttributes 値を取得するには、最初に type を取得します。type から ParameterInfo 配列を取得します。 ParameterAttributes 値は、この配列に格納されています。
これらの列挙値は、省略可能なメタデータに依存します。すべての属性をすべてのコンパイラで使用できるわけではありません。該当するコンパイラのドキュメントを参照し、使用できる列挙値を確認してください。
メンバ
メンバ名 | 説明 | 値 |
---|---|---|
HasDefault
.NET Compact Framework でもサポート。 |
パラメータが既定値を持つことを指定します。 | 4096 |
HasFieldMarshal
.NET Compact Framework でもサポート。 |
パラメータがフィールド マーシャリング情報を持つことを指定します。 | 8192 |
In
.NET Compact Framework でもサポート。 |
パラメータが入力パラメータであることを指定します。 | 1 |
Lcid
.NET Compact Framework でもサポート。 |
パラメータがロケール識別子 (LCID: LoCale Identifier) であることを指定します。 | 4 |
None
.NET Compact Framework でもサポート。 |
パラメータ属性がないことを指定します。 | 0 |
Optional
.NET Compact Framework でもサポート。 |
パラメータが省略可能であることを指定します。 | 16 |
Out
.NET Compact Framework でもサポート。 |
パラメータが出力パラメータであることを指定します。 | 2 |
Reserved3
.NET Compact Framework でもサポート。 |
予約済み。 | 16384 |
Reserved4
.NET Compact Framework でもサポート。 |
予約済み。 | 32768 |
ReservedMask
.NET Compact Framework でもサポート。 |
パラメータが予約済みであることを指定します。 | 61440 |
Retval
.NET Compact Framework でもサポート。 |
パラメータが戻り値を持つことを指定します。 | 8 |
使用例
[Visual Basic, C#, C++] 指定したパラメータの属性を表示する例を次に示します。
Imports System
Imports System.Reflection
Imports Microsoft.VisualBasic
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
[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;
}
}
[C++]
#using <mscorlib.dll>
using namespace System;
using namespace System::Reflection;
using namespace System::Runtime::InteropServices;
public __gc class paramatt
{
public:
static void mymethod (String* str1, [Out] String** str2, String** str3)
{
*str2 = S"string";
}
};
int main()
{
Console::WriteLine(S"\nReflection.ParameterAttributes");
// Get the Type and the method.
Type* Mytype = Type::GetType(S"paramatt");
MethodBase* Mymethodbase = Mytype->GetMethod(S"mymethod");
// Display the method.
Console::Write(S"\nMymethodbase = {0}", 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(S"\nFor the second parameter:\nMyparamattributes = {0}, which is an {1}",
__box((int)Myparamattributes), __box(Myparamattributes));
return 0;
}
[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン をクリックします。
必要条件
名前空間: System.Reflection
プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ, .NET Compact Framework - Windows CE .NET
アセンブリ: Mscorlib (Mscorlib.dll 内)