C# ParameterInfo IsIn

Description

ParameterInfo IsIn Gets a value indicating whether this is an input parameter.

Syntax

ParameterInfo.IsIn has the following syntax.


public bool IsIn { get; }

Example


using System;//  w  w w .  j  a  v  a  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);
         }
      }
   }
}




















Home »
  C# Tutorial »
    System.Reflection »




EventInfo
FieldInfo
MemberInfo
MethodInfo
ParameterInfo
TypeInfo