Abstract base classes that implement an interface

前端 未结 3 1386
鱼传尺愫
鱼传尺愫 2020-12-04 18:50

Let\'s say that I have an abstract base class something simple like

abstract class Item : IDisplayable
    {
        public int Id { get; set; }
        pub         


        
3条回答
  •  执笔经年
    2020-12-04 19:07

    Since Item inherits from IDisplayable, anything that derives from Item must also implement IDisplayable. So explicitly adding IDisplayable to those classes is redundant.

    EDIT: @EricLippert makes an excellent point below about the effect of re-implementing interfaces. I'm leaving this answer to preserve the discussion in the comments.

提交回复
热议问题