i have a class with a static field and a static function, e.g. like this
public class A {
protected static string[] _eventField = new[] { "SomeValue" };
public static TOut DoSomethingThatDependsOnEventField(TIn input){
//output depends on input and the static _eventField
}
public class Nested1: A {
protected new static string[] _eventField = new[] { "SomethingDifferent" };
}
public class Nested2 : A {
protected new static string[] _eventField = new[] { "SomethingElse" };
}
}
The output and input types of that static method are of no importance here, the only relevant thing is that the output - despite relying on the input, of course - depends on the content of the static field. The implementation of the method doesn't change at all in the derived classes, and all I want is to change that very static field. But whenever I do a call like
var res1 = A.Nested1.DoSomethingThatDependsOnEventField(...);
or var res2 = A.Nested2.DoSomethingThatDependsOnEventField(...);
the incorrect static field from the base class A is referenced from within the method.
That is, the intended "hiding" / "redefining" of the static field via protected new static string[] _eventField = ...
doesn't work - Why is that so?