0

If I declare my own interface I can't get declared methods

public interface ITest
{
    string TestProp { get; set; }
    void TestMethod();
}

MethodInfo[] declaredMethods = typeof(ITest).GetDeclaredMethods();
//declaredMethods.Length == 0
MethodInfo[] methods = typeof(ITest).GetMethods();
//methods.Length == 0

If I try to get declared methods on some other interface (IEnumerable for example) it works just fine.

Can anyone help me understand what I'm doing wrong.

Thank you!

gregorj
  • 33
  • 4
  • Do you mean something like this?: `MethodInfo[] declaredMethods = typeof (IEnumerable).GetMethods(BindingFlags.DeclaredOnly);` `GetDeclaredMethods` receives a string name as parameter – Adolfo Perez May 30 '14 at 14:29
  • It works for built in interfaces. It does not work if I invoke GetMethods on my own interfaces. I'm wondering what's the difference between my interface and built in – gregorj May 30 '14 at 17:38

0 Answers0