Force subclasses of an interface to implement ToString

后端 未结 7 2126
猫巷女王i
猫巷女王i 2020-12-28 11:19

Say I have an interface IFoo and I want all subclasses of IFoo to override Object\'s ToString method. Is this possible?

Simpl

7条回答
  •  感动是毒
    2020-12-28 12:14

    abstract class Foo
    {
        public override abstract string ToString();
    }
    
    class Bar : Foo
    {
        // need to override ToString()
    }
    

提交回复
热议问题