static menthods in interfaces
I want to create an interface with static methods so i can override these in a class.
I know statics are class-level, but it doesnt seem right that an interface shouldnt allow a child class to override static methods.
is there a work around or a keyword im missing?
The reason is that im trying to mock an interface using NMock and it only supports interfaces as mockable types. As im working with some elses code, there are very few interfaces and most classes are static upto their eyeballs
Sean GPosted Jul 23, 2007, 6:24 AM
AlanPosted Jul 20, 2007, 9:04 AM
There's then no problem in the singletons implementing an interface and providing their own implementation of its methods/properties.
AlanPosted Jul 20, 2007, 8:49 AM
However, as an alternative to implementing an interface, you can inherit from an abstract class as long as the classes which you want to implement the static methods don't already inherit from another class (except, of course, System.Object).
Notice though that, even in abstract classes, static methods and properties are never virtual though they can hide the base class implementation (or lack of one) with their own.