[Mono-devel-list] Bug with static field initializers
Chris Seaton
chris at chrisseaton.com
Thu Sep 11 11:23:25 EDT 2003
Look at the code below. From an abstract overview you would expect it to
print 14, but the output is 0 (it's clear why, x is initialized before
y, so when Foo is constructed for x, y is still 0). Is this actually a
bug, or an excepted restriction?
class Foo
{
public int z;
public Foo()
{
z = Bar.y;
}
}
class Bar
{
public static Foo x = new Foo();
public static int y = 14;
public static void Main()
{
System.Console.WriteLine(x.z);
}
}
More information about the Mono-devel-list
mailing list