Why isn't the static constructor in Derived invoked in the following code?
class Base
{
public static Base Instance;
static Base() { Console.WriteLine("Static Base invoked."); }
}
class Derived : Base
{
static Derived() {
Instance = new Derived();
Console.WriteLine("Static Derived invoked.");
}
}
void Main()
{
var instance = Derived.Instance;
}
OUTPUT:
Static Base invoked.