Export (0) Print
Expand All

ParameterInfo.IsOut Property

Gets a value indicating whether this is an output parameter.

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

public bool IsOut { get; }
/** @property */
public boolean get_IsOut ()

public function get IsOut () : boolean

Property Value

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.

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
 */

import System.*;
import System.Reflection.*;

class Parminfo
{   
    public static void Mymethod(int int1m, 
		/**	@ref
		 */ String str2m,
        /**	@ref
         */ String str3m)
    {
        str2m = "in mymethod";
    } //Mymethod

    public static void 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.
        for(int iCtr=0; iCtr < myArray.length; iCtr++) {
            ParameterInfo myParam = myArray[iCtr];
            Console.Write(("\nFor parameter # " + myParam.get_Position() 
                + ", the IsOut is - " 
                + ((System.Boolean) myParam.get_IsOut())));
        }
    } //main
} //Parminfo
/*
 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 - False
 For parameter # 2, the IsOut is - False
 */

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0

Community Additions

ADD
Show:
© 2014 Microsoft