小编Mat*_*ttS的帖子

对于某些lambda表达式,为什么Action.Method.IsStatic在Visual Studio 2013和2015之间有所不同

鉴于以下控制台程序:

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年的输出是正确的.

c# roslyn visual-studio-2013 visual-studio-2015

5
推荐指数
1
解决办法
102
查看次数