Type.GetMethods : MethodInfo « Reflection « C# / C Sharp






Type.GetMethods

    

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.MethodInfo: Name
2.List Assembly Info
3.dump the public methods of a class
4.Finding the class that contains a method in an assembly.
5.Invoke methods using reflectionInvoke methods using reflection
6.Analyze methods using reflectionAnalyze methods using reflection
7.dynamic invocation is demonstrated with MethodInfo.Invoke and Type.InvokeMember
8.Invokes the method.
9.Call a static method in a nested namespace.
10.Gets a MethodBody that provides access to the MSIL stream, local variables, and exceptions for the current method.
11.Gets the parameters of the specified method or constructor.
12.Invokes the method or constructor represented by the current instance, using the specified parameters.
13.Gets a value indicating whether the method is abstract.
14.Indicating whether the potential visibility of this method or constructor is described by MethodAttributes.Assembly
15.Gets a value indicating whether this method is final.
16.Is it a public method.
17.MethodInfo List