As a relative newbie I try to read as much as I can about a particular subject and test/write as much code as I can. I was looking at one of Jons Brainteasers (question #2) and my output was different than the answer. Which makes brings me here to ask if something has changed in recent versions and to see what output others are getting from this code.
The question is, "What will be displayed, why, and how confident are you?"
using System;
class Foo
{
static Foo()
{
Console.WriteLine ("Foo");
}
}
class Bar
{
static int i = Init();
static int Init()
{
Console.WriteLine("Bar");
return 0;
}
}
class Test
{
static void Main()
{
Foo f = new Foo();
Bar b = new Bar();
}
}
What, if anything, would cause us to get two different answers?