ParameterInfo.IsOut 속성
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
출력 매개 변수인지 여부를 나타내는 값을 가져옵니다.
public:
property bool IsOut { bool get(); };
public bool IsOut { get; }
member this.IsOut : bool
Public ReadOnly Property IsOut As Boolean
속성 값
true매개 변수가 출력 매개 변수이면 이고, 그렇지 않으면 . false
예제
다음 예제에서는 , ParameterAttributes.Out및 ParameterAttributes.Optional 특성에 대한 메서드 매개 변수를 테스트하는 ParameterAttributes.In방법을 보여 있습니다.
이 예제에는 다음을 DefineMethod 수행하는 메서드가 포함되어 있습니다.
형식을 포함하는 동적 어셈블리를
MyType만듭니다.에
MyMethod메서드를 추가합니다MyType.MyMethod에는 세 개의 매개 변수가 있습니다. 첫 번째 매개 변수는 다음으로 ParameterAttributes.In정의되고, 두 번째 매개 변수는 다음으로 ParameterAttributes.Out정의되고, 세 번째 매개 변수는 .와 함께 ParameterAttributes.Optional정의됩니다.형식을 완료하기 위한 호출 TypeBuilder.CreateType 입니다.
실행 DefineMethod후 예제에서는 동적 어셈블리를 찾을 때까지 현재 로드된 어셈블리를 검색합니다. 어셈블리에서 로드하고MyType, 메서드에 대한 개체를 MyMethod 가져오 MethodInfo 고, 매개 변수를 검사합니다. 이 예제에서는 , IsOut및 IsOptional 속성을 사용하여 IsIn매개 변수에 대한 정보를 표시합니다.
using System;
using System.Reflection;
class parminfo
{
public static void mymethod (
int int1m, out string str2m, ref string str3m)
{
str2m = "in mymethod";
}
public static int Main(string[] args)
{
Console.WriteLine("\nReflection.Parameterinfo");
//Get the ParameterInfo parameter of a function.
//Get the type.
Type Mytype = Type.GetType("parminfo");
//Get and display the method.
MethodBase Mymethodbase = Mytype.GetMethod("mymethod");
Console.Write("\nMymethodbase = " + Mymethodbase);
//Get the ParameterInfo array.
ParameterInfo[] Myarray = Mymethodbase.GetParameters();
//Get and display the IsOut of each parameter.
foreach (ParameterInfo Myparam in Myarray)
{
Console.Write ("\nFor parameter # " + Myparam.Position
+ ", the IsOut is - " + Myparam.IsOut );
}
return 0;
}
}
/*
This code produces the following output:
Reflection.ParameterInfo
Mymethodbase = Void mymethod (int, System.String ByRef, System.String ByRef)
For parameter # 0, the IsOut is - False
For parameter # 1, the IsOut is - True
For parameter # 2, the IsOut is - False
*/
Imports System.Reflection
Class parminfo
Public Shared Sub mymethod(int1m As Integer, ByRef str2m As String, _
ByRef str3m As String)
str2m = "in mymethod"
End Sub
Public Shared Function Main() As Integer
Console.WriteLine(ControlChars.CrLf + "Reflection.Parameterinfo")
'Get the ParameterInfo parameter of a function.
'Get the type.
Dim Mytype As Type = Type.GetType("parminfo")
'Get and display the method.
Dim Mymethodbase As MethodBase = Mytype.GetMethod("mymethod")
Console.Write(ControlChars.CrLf + "Mymethodbase = " _
+ Mymethodbase.ToString())
'Get the ParameterInfo array.
Dim Myarray As ParameterInfo() = Mymethodbase.GetParameters()
'Get and display the IsOut of each parameter.
Dim Myparam As ParameterInfo
For Each Myparam In Myarray
Console.Write(ControlChars.CrLf _
+ "For parameter # " + Myparam.Position.ToString() _
+ ", the IsOut is - " + Myparam.IsOut.ToString())
Next Myparam
Return 0
End Function
End Class
' This code produces the following output:
'
' Reflection.ParameterInfo
'
' Mymethodbase = Void mymethod (Int32, System.String ByRef, System.String ByRef)
' For parameter # 0, the IsOut is - False
' For parameter # 1, the IsOut is - True
' For parameter # 2, the IsOut is - False
설명
이 메서드는 선택적 메타데이터 플래그에 따라 달라집니다. 이 플래그는 컴파일러에서 삽입할 수 있지만 컴파일러는 이 작업을 수행할 의무가 없습니다.
이 메서드는 Out 열거자의 플래그를 ParameterAttributes 활용합니다.
배열을 ParameterInfo 얻으려면 먼저 메서드 또는 생성자를 가져와서 호출 MethodBase.GetParameters합니다.