ParameterAttributes 열거형
정의
매개 변수와 관련될 수 있는 특성을 정의합니다.Defines the attributes that can be associated with a parameter. 이러한 특성은 CorHdr.h에 정의됩니다.These are defined in CorHdr.h.
이 열거형에는 멤버 값의 비트 조합을 허용하는 FlagsAttribute 특성이 있습니다.
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
- 상속
- 특성
필드
HasDefault | 4096 | 매개 변수가 기본값을 갖도록 지정합니다.Specifies that the parameter has a default value. |
HasFieldMarshal | 8192 | 매개 변수에 필드 마샬링 정보가 포함되도록 지정합니다.Specifies that the parameter has field marshaling information. |
In | 1 | 매개 변수가 입력 매개 변수가 되도록 지정합니다.Specifies that the parameter is an input parameter. |
Lcid | 4 | 매개 변수가 lcid(로캘 식별자)가 되도록 지정합니다.Specifies that the parameter is a locale identifier (lcid). |
None | 0 | 매개 변수 특성이 없도록 지정합니다.Specifies that there is no parameter attribute. |
Optional | 16 | 매개 변수를 선택적 요소로 지정합니다.Specifies that the parameter is optional. |
Out | 2 | 매개 변수가 출력 매개 변수가 되도록 지정합니다.Specifies that the parameter is an output parameter. |
Reserved3 | 16384 | 예약되어 있습니다.Reserved. |
Reserved4 | 32768 | 예약되어 있습니다.Reserved. |
ReservedMask | 61440 | 매개 변수가 예약되도록 지정합니다.Specifies that the parameter is reserved. |
Retval | 8 | 매개 변수가 반환 값이 되도록 지정합니다.Specifies that the parameter is a return value. |
예제
다음 예에서는 지정 된 매개 변수의 특성을 표시 합니다.The following example displays the attributes of the specified parameter.
using namespace System;
using namespace System::Reflection;
using namespace System::Runtime::InteropServices;
public ref class paramatt
{
public:
static void mymethod( String^ str1, [Out]interior_ptr<String^> str2, interior_ptr<String^> str3 )
{
*str2 = "string";
}
};
int main()
{
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 = {0}", Mymethodbase );
// Get the ParameterInfo array.
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 = {0}, which is an {1}", (int)Myparamattributes, Myparamattributes );
return 0;
}
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
.To get the ParameterAttributes
value, first get the Type
. 에서 Type
ParameterInfo
배열을 가져옵니다.From the Type
, get the ParameterInfo
array. ParameterAttributes
값은 배열 내에 있습니다.The ParameterAttributes
value is within the array.
이러한 열거자 값은 선택적 메타 데이터에 따라 달라 집니다.These enumerator values are dependent on optional metadata. 모든 특성을 모든 컴파일러에서 사용할 수 있는 것은 아닙니다.Not all attributes are available from all compilers. 사용할 수 있는 열거 값을 확인 하려면 적절 한 컴파일러 지침을 참조 하십시오.See the appropriate compiler instructions to determine which enumerated values are available.