Sealing an interface after implementing it

前端 未结 5 461
天命终不由人
天命终不由人 2021-01-02 16:00

I am working on a small project and I came across that problem.

The project output is a library containing an interface. I would like to implement that interface and

5条回答
  •  情歌与酒
    2021-01-02 16:28

    Why not use an abstract class like below.

    Haven't tested it but this should work?

    public abstract class Test
    {
        public virtual void SomeMethod() {}
        //OR
        public abstract void SomeMethod();//MSDN says:
        //an abstract method is implicitly virtual
    }
    
    class A : Test
    {
        public sealed override SomeMethod()
        {
    
        }
    }
    

提交回复
热议问题