C# interface inheritance

前端 未结 4 1049
春和景丽
春和景丽 2021-01-01 17:45

Given:

public interface IA
{
    void TestMethod();
}

public interface IB : IA
{
}

Why:

typeof(IB).GetMethods().Count() ==         


        
4条回答
  •  感动是毒
    2021-01-01 18:38

    This seems to be the design of the GetMethods function. It doesn't support inherited members in interfaces. If you want to discover all the methods, you need to query each interface type directly.

    Check out the community content section of this MSDN article.

提交回复
热议问题