Type.GetMethods : MethodInfo : Reflection C# Source Code


Custom Search

C# Source Code » Reflection » MethodInfo »

 

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

 
    
   
  
   







HTML code for linking to this page:

Follow Navioo On Twitter

C# Source Code

 Navioo Reflection
» MethodInfo