Export (0) Print
Expand All

ParameterInfo.IsOut Property

Gets a value indicating whether this is an output parameter.

Namespace:  System.Reflection
Assemblies:   System.Reflection (in System.Reflection.dll)
  mscorlib (in mscorlib.dll)

'Declaration
Public ReadOnly Property IsOut As Boolean

Property Value

Type: System.Boolean
true if the parameter is an output parameter; otherwise, false.

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.

The following example shows how to test method parameters for the ParameterAttributes.In, ParameterAttributes.Out, and ParameterAttributes.Optional attributes.

The example contains a DefineMethod method that does the following:

After executing DefineMethod, the example searches the assemblies that are currently loaded until it finds the dynamic assembly. It loads MyType from the assembly, gets a MethodInfo object for the MyMethod method, and examines the parameters. The example uses the IsIn, IsOut, and IsOptional properties to display information about the parameters.

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 

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0, 1.1

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Portable Class Library

Supported in: Portable Class Library

Supported in: Windows Phone 8.1

Supported in: Windows Phone Silverlight 8.1

Supported in: Windows Phone Silverlight 8
Show:
© 2015 Microsoft