C# ParameterInfo IsOut
Description
ParameterInfo IsOut
Gets a value indicating whether
this is an output parameter.
Syntax
ParameterInfo.IsOut
has the following syntax.
public bool IsOut { get; }
Example
using System;/*from ww w . j a va 2 s .c o m*/
using System.Reflection;
using System.Threading;
using System.Reflection.Emit;
public class ParameterInfo_IsIn_IsOut_IsOptional
{
public static void Main()
{
Assembly[] myAssemblies = Thread.GetDomain().GetAssemblies();
Assembly myAssembly = null;
for(int i = 0; i < myAssemblies.Length; i++)
if(String.Compare(myAssemblies[i].GetName(false).Name, "MyAssembly") == 0)
myAssembly = myAssemblies[i];
if(myAssembly != null)
{
Type myType = myAssembly.GetType("MyType");
MethodBase myMethodBase = myType.GetMethod("MyMethod");
ParameterInfo[] myParameters = myMethodBase.GetParameters();
for(int i = 0; i < myParameters.Length; i++)
{
if(myParameters[i].IsIn)
Console.WriteLine("\tThe {0} parameter has the In attribute",
i + 1);
if(myParameters[i].IsOptional)
Console.WriteLine("\tThe {0} parameter has the Optional attribute",
i + 1);
if(myParameters[i].IsOut)
Console.WriteLine("\tThe {0} parameter has the Out attribute",
i + 1);
}
}
}
}