ParameterInfo::IsOut Property


Gets a value indicating whether this is an output parameter.

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

property bool IsOut {
	bool get();

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.

using namespace System;
using namespace System::Reflection;
using namespace System::Runtime::InteropServices;
public ref class parminfo
   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:


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

Universal Windows Platform
Available since 8
.NET Framework
Available since 1.1
Portable Class Library
Supported in: portable .NET platforms
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Windows Phone
Available since 8.1
Return to top