Reputation: 112857
(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?
Upvotes: 8
Views: 2696
Reputation: 55132
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 ();
}
Upvotes: 12