views:

68

answers:

3

If I have a subclass that has yet to implement a function provided by the base class, I can override that function and have it throw a NotSupportedException. Is there a way to generate a compile-time error for this to avoid only hitting this at runtime?

Update: I can't make the base class abstract.

+1  A: 

Make it abstract with no implementation and fail to implement it in the derived class.

Matt Hinze
+2  A: 

You can make the base class abstract:

abstract class Foo
{
 public abstract void Bar();
}

Now, any subclass must implement Bar(), or it won't compile.

Khoth
+1  A: 

[Obsolete("This still needs implementing", true/false)] true if you don't want the build to succeed, false if you just want a warning

Slightly hackish ... but it does the job of warning at compile time.

MagicKat