This documentation is archived and is not being maintained.

ParameterInfo.IsOut Property

Gets a value indicating whether this is an output parameter.

[Visual Basic]
Public ReadOnly Property IsOut As Boolean
[C#]
public bool IsOut {get;}
[C++]
public: __property bool get_IsOut();
[JScript]
public function get IsOut() : Boolean;

Property Value

true if the parameter is an output parameter; otherwise, false.

Remarks

This method depends on an optional metadata flag. This flag can be inserted by compilers, but the compilers are not obligated to do so.

This method utilizes the Out flag of the ParameterAttributes enumerator.

To get the ParameterInfo array, first get the method or the constructor and then call MethodBase.GetParameters.

Example

[Visual Basic] 
Imports System
Imports System.Reflection
Imports Microsoft.VisualBasic

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 

[C#] 
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 (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
 */

[C++] 
#using <mscorlib.dll>
using namespace System;
using namespace System::Reflection;
using namespace System::Runtime::InteropServices;

public __gc class parminfo
{
public:
    static void mymethod (int int1m, [Out] String** str2m, String** str3m)
    {
        *str2m = S"in mymethod";
    }
};

int main()
{
    Console::WriteLine(S"\nReflection.Parameterinfo");

    //Get the ParameterInfo parameter of a function.

    //Get the type.
    Type* Mytype = Type::GetType(S"parminfo");

    //Get and display the method.
    MethodBase* Mymethodbase = Mytype->GetMethod(S"mymethod");
    Console::Write(S"\nMymethodbase = {0}", Mymethodbase);

    //Get the ParameterInfo array.
    ParameterInfo* Myarray[] = Mymethodbase->GetParameters();

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

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also

ParameterInfo Class | ParameterInfo Members | System.Reflection Namespace

Show: