views:

84

answers:

1

(I'm working in .NET 4.0 beta, C#.)

I have an interface, and all classes derived from this interface should implement custom ToString() logic. Is that enforceable? If so, how?

+6  A: 

Not through an interface.

You'll need to use an abstract class for this.

-- Edit

You can just re-declare 'ToString' as abstract:

abstract class Foo
{
    public override abstract string ToString ();
}
Noon Silk