ParameterInfo.IsOut 속성

정의

이 매개 변수가 출력 매개 변수인지 여부를 나타내는 값을 가져옵니다.

public:
 property bool IsOut { bool get(); };
public bool IsOut { get; }
member this.IsOut : bool
Public ReadOnly Property IsOut As Boolean

속성 값

Boolean

매개 변수가 출력 매개 변수이면 true이고, 그렇지 않으면 false입니다.

예제

다음 예제에서는 , ParameterAttributes.OutParameterAttributes.Optional 특성에 대한 메서드 매개 변수를 테스트하는 ParameterAttributes.In방법을 보여 있습니다.

이 예제에는 다음을 DefineMethod 수행하는 메서드가 포함되어 있습니다.

실행 후 DefineMethod예제에서는 동적 어셈블리를 발견할 때까지 현재 로드된 어셈블리를 검색합니다. 어셈블리에서 로드하고MyType, 메서드에 대한 개체를 MyMethod 가져오 MethodInfo 고, 매개 변수를 검사합니다. 이 예제에서는 , IsOutIsOptional 속성을 사용하여 IsIn매개 변수에 대한 정보를 표시합니다.

using namespace System;
using namespace System::Reflection;
using namespace System::Runtime::InteropServices;
public ref class parminfo
{
public:
   static void mymethod( int int1m, [Out]interior_ptr<String^> str2m, interior_ptr<String^> str3m )
   {
       *str2m = "in mymethod";
   }

};

int main()
{
   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 = {0}", Mymethodbase );
   
   //Get the ParameterInfo array.
   array<ParameterInfo^>^Myarray = Mymethodbase->GetParameters();
   
   //Get and display the IsOut of each parameter.
   System::Collections::IEnumerator^ enum0 = Myarray->GetEnumerator();
   while ( enum0->MoveNext() )
   {
      ParameterInfo^ Myparam = safe_cast<ParameterInfo^>(enum0->Current);
      Console::Write( "\nFor parameter # {0}, the IsOut is - {1}", Myparam->Position, Myparam->IsOut );
   }

   return 0;
}

/*
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
*/
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합니다.

적용 대상