You can find it using System.Reflection.MethodInfo
Suppose you have a class with the following methods in interfaces:
public interface IFaceOne { void MethodA(); } public interface IFaceTwo { void MethodB(); } public class MyClass: IFaceOne, IFaceTwo { public int myIntField; public string myStringField; private double myDoubleField = 0; public double getMyDouble(){ return myDoubleField; } public void myMethod(int p1, string p2) { } public int MyProp { get { return myIntField; } set { myIntField = value; } } public void MethodA() {} public void MethodB() {} }
Then use the following code to read all methods / properties:
public static void Main(string[] args) { TheType.MyClass aClass = new TheType.MyClass(); Type t = aClass.GetType(); MethodInfo[] mi = t.GetMethods(); foreach(MethodInfo m in mi) Console.WriteLine("Method: {0}", m.Name); }
You will get the following result:
Method: getMyDouble
Method: myMethod
Method: get_MyProp
Method: set_MyProp
Method: MethodA
Method: MethodB
Method: ToString
Method: equal
Method: GetHashCode
Method: GetType
source share