Watch窗口中的$ ReturnValue在VS2015中不起作用

dem*_*key 8 c# watch visual-studio-2015

在VS2013中,我们可以通过检查一个名为的Watch窗口条目来查看方法的返回值$ReturnValue.这在VS2015中似乎不起作用.

例如,我制作了一个新的控制台应用程序,包含以下代码:

using System;

namespace ReturnInspector
{
    public class Program
    {
        public static void Main(string[] args)
        {
            Console.WriteLine("Number: {0}", Method1());
        }

        public static int Method1()
        {
            return Method2(1000);          //A
        }                                  //B

        private static int Method2(int i)
        {
            return i + 42;
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

如果我在线上设置一个断点//A,那么一旦它断开,F10一步一步//B,$ReturnValueWatch窗口中的项目在VS2013中显示"1042",但在VS2015中它显示如下:

error CS0103: The name '$ReturnValue' does not exist in the current context
Run Code Online (Sandbox Code Playgroud)

请注意,Autos和Locals窗口正确地说明了这一点:

ReturnInspector.Program.Method2 returned    1042
Run Code Online (Sandbox Code Playgroud)

有谁知道$ReturnValue在VS2015中Watch窗口功能是否被删除了?

Ehs*_*jad 9

确保您在工具>>选项>>调试>>中使用选中的旧C#和VB表达式计算器选项.

来自MSDN:

您必须打开旧版表达式计算器才能识别$ ReturnValue(工具/选项/调试/使用旧版C#和VB表达式计算器).否则,您可以使用$ ReturnValue1.