Why isn't the static constructor of the parent class called when invoking a method on a nested class
- by Ryan Ische
Given the following code, why isn't the static constructor of "Outer" called after the first line of "Main"?
namespace StaticTester
{
class Program
{
static void Main( string[] args )
{
Outer.Inner.Go();
Console.WriteLine();
Outer.Go();
Console.ReadLine();
}
}
public static partial class Outer
{
static Outer()
{
Console.Write( "In Outer's static constructor\n" );
}
public static void Go()
{
Console.Write( "Outer Go\n" );
}
public static class Inner
{
static Inner()
{
Console.Write( "In Inner's static constructor\n" );
}
public static void Go()
{
Console.Write( "Inner Go\n" );
}
}
}
}