ParameterInfo: GetParameters : ParameterInfo « Reflection « C# / C Sharp






ParameterInfo: GetParameters

    

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;
            }
        }
    }
}

   
    
    
  








Related examples in the same category

1.Dumping the methods and their parameters for a class.
2.Dumps the properties names and current values from an object type (used for static classes)
3.Dumps the properties names and current values from an object
4.Gets the attributes for this parameter.
5.Gets all the custom attributes defined on this parameter.
6.If attribute of the type or its derived types is applied
7.Gets a value indicating whether this is an output parameter.
8.Gets the name of the parameter.
9.Gets the Type of this parameter.
10.Append Generic Type parameters to StringBuilder