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
- 상속
- 특성
필드
| Name | 값 | Description |
|---|---|---|
| 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 배열 내에 있습니다.
이러한 열거자 값은 선택적 메타데이터에 따라 달라집니다. 모든 특성이 모든 컴파일러에서 사용할 수 있는 것은 아닙니다. 사용 가능한 열거형 값을 확인하려면 적절한 컴파일러 지침을 참조하세요.