Interface inheritance: is extending properties possible?

后端 未结 7 1193
庸人自扰
庸人自扰 2021-02-03 23:32

I want to do this:

interface IBase
{
    string Property1 { get; }
}

interface IInherited : IBase
{
    string Property1 { get; set; }
}

So th

相关标签:
7条回答
  • 2021-02-04 00:16

    Hiding a member is violating the Liskov Substitution Principle and pretty much just shouldn't be done, ever. By hiding this member you are introducing a very difficult to locate bug since 2 different outcomes will occur depending whether you cast the object as ((IInherited).Property1) or cast it to ((IBase).Property1).

    http://en.wikipedia.org/wiki/Liskov_substitution_principle

    0 讨论(0)
提交回复
热议问题