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

AlanRank #669 · 3.6K reputationPosted Jul 20, 2007, 4:49 AM EDT
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.
AlanRank #669 · 3.6K reputationPosted Jul 20, 2007, 5:04 AM EDT
There's then no problem in the singletons implementing an interface and providing their own implementation of its methods/properties.
Sean G15 reputationPosted Jul 23, 2007, 2:24 AM EDT