Explicit interface implementation cannot be virtual

后端 未结 5 1732
遥遥无期
遥遥无期 2021-02-05 13:20

For the record, I\'ve already seen this connect item but I can\'t really understand what would be the problem in supporting this.

Say I have the following code:

5条回答
  •  孤城傲影
    2021-02-05 13:25

    If there is only one interface that is being inherited from, why do you need to do:

    public class Base : IInterface
    {
        virtual void IInterface.Method()
        {
           throw new NotImplementedException();
        }
    }
    

    Why not just go:

    public class Base : IInterface
    {
       virtual void Method()
       {
          throw new NotImplementedException();
       }
    }
    

提交回复
热议问题