作为一个相对新手,我会尽可能多地阅读关于某个特定主题的内容,并尽可能多地测试/编写代码。我看着其中一个Jons Brainteasers (问题#2),我的输出与答案不同。这使得我在这里询问在最近的版本中是否有什么变化,并看看其他人从这段代码中得到了什么输出。
问题是,“将展示什么,为什么,以及你有多自信?”
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();
}
}
什么会导致我们得到两个不同的答案?
https://stackoverflow.com/questions/1645254
复制相似问题