Mega Code Archive

 
Categories / C# / Reflection
 

ParameterInfo

using System; using System.Reflection; public class Class1 {     public static int Main() {         Type t = typeof(MyClass);         Console.WriteLine("Type of class: " + t);         Console.WriteLine("Namespace: " + t.Namespace);         MethodInfo[] mi = t.GetMethods();         Console.WriteLine("Methods are:");         foreach (MethodInfo i in mi) {             Console.WriteLine("Name: " + i.Name);             ParameterInfo[] pif = i.GetParameters();             foreach (ParameterInfo p in pif) {                 Console.WriteLine("Type: " + p.ParameterType + " parameter name: " + p.Name);             }         }         return 0;     }     public class MyClass {         public int pubInteger;         private int _privValue;         public MyClass() {         }         public MyClass(int IntegerValueIn) {             pubInteger = IntegerValueIn;         }         public int Add10(int IntegerValueIn) {             Console.WriteLine(IntegerValueIn);             return IntegerValueIn + 10;         }         public int TestProperty {             get {                 return _privValue;             }             set {                 _privValue = value;             }         }     } }