鉴于以下控制台程序:
class Program
{
private static string _value;
static void Main(string[] args)
{
var t = new Action(() => _value = "foo");
Console.Out.WriteLine("t.Method.IsStatic: {0}", t.Method.IsStatic);
}
}
Run Code Online (Sandbox Code Playgroud)
当使用VS 2013针对.Net 4.5.2编译时,它将打印出来
t.Method.IsStatic: true
Run Code Online (Sandbox Code Playgroud)
当使用VS 2015针对.Net 4.5.2编译时,它将打印出来
t.Method.IsStatic: false
Run Code Online (Sandbox Code Playgroud)
从这个问题,我有点理解发生了什么,但我很困惑为什么VS的版本之间的行为发生了变化.根据我的理解,2013年的输出是正确的.