S
spenular
I'm wondering of a way to implement functionality that would force an
inherited class to implement a static method. Here is an example:
public class MyBase
{
public static void DoSomething()
{
// This method must be implemented by all inherited classes
......
}
}
public class MyClass : MyBase
{
public new static void DoSomething()
{
.....
}
}
Note that the class MyBase has a static method defined (DoSomething).
Since the method is marked as static, it can neither be marked as
virtual or abstract. What I need is to force all inherited classes to
implement the method and I need the method to be static. I've also
tried creating an interface, however, interfaces cannot contain static
method definitions. Is anyone aware of a design pattern or method that
would do something like this?
inherited class to implement a static method. Here is an example:
public class MyBase
{
public static void DoSomething()
{
// This method must be implemented by all inherited classes
......
}
}
public class MyClass : MyBase
{
public new static void DoSomething()
{
.....
}
}
Note that the class MyBase has a static method defined (DoSomething).
Since the method is marked as static, it can neither be marked as
virtual or abstract. What I need is to force all inherited classes to
implement the method and I need the method to be static. I've also
tried creating an interface, however, interfaces cannot contain static
method definitions. Is anyone aware of a design pattern or method that
would do something like this?