Given
public class Original {
public static DoStuff() {
}
}
public class Derived : Original {
}
when calling
Derived.DoStuff();
Weirdness of the requirement aside, is it possible within DoStuff() to detect the class that it was called on?
i.e. is it possible within the implementation of DoStuff() to tell the difference between Original.DoStuff(); and Derived.DoStuff();
Not in C#, no – the compiled IL refers directly to
Original.DoStuff.(I’ve just verified that VB apparently does the same thing for static calls, whereas IIRC there’s a difference between VB and C# in the generated code when calling a virtual method via a “child” reference.)