Get Method Paramemters : Reflection Assembly : Development Class C# Source Code


Custom Search

C# Source Code » Development Class » Reflection Assembly »

 

Get Method Paramemters









    


using System;
using System.Reflection;


public class Test
{
    public static void Main(string[] args)
    {
    Assembly a = null;
        AssemblyName asmName;
      asmName = new AssemblyName();
      asmName.Name = "Test";
      Version v = new Version("1.0.454.30104");
      asmName.Version = v;
 
        a = Assembly.Load(asmName);

    Type testClassName = a.GetType("Test");
    MethodInfo mi = testClassName.GetMethod("Main");  
    Console.WriteLine("Here are the params for {0}", mi.Name);
 
    // Show number of params.
    ParameterInfo[] myParams = mi.GetParameters();
    Console.WriteLine("Method has {0} params", myParams.Length);
    
    // Show info about param.
    foreach(ParameterInfo pi in myParams)
    {
      Console.WriteLine("Param name: {0}", pi.Name);
      Console.WriteLine("Position in method: {0}", pi.Position);        
      Console.WriteLine("Param type: {0}", pi.ParameterType);
    }
    }
}



           
       
    
   
  
   







HTML code for linking to this page:

Follow Navioo On Twitter

C# Source Code

 Navioo Development Class
» Reflection Assembly