在VS2017中调试。无法查看静态方法中声明的常量值

问题描述 投票:0回答:1

作为示例,我有简单的控制台应用程序:

namespace Temp
{
    class Program
    {
        const double GlobalEps = 0.01;

        static void Main(string[] args)
        {
            const double LocalEps = 0.01;

            var result1 = 0.001 < GlobalEps;
            var result2 = 0.001 < LocalEps;
            var result3 = 0.011 < LocalEps;
        }
    }
}

no description, just an image

所以,我在调试中看不到“LocalEps”常量的值,在观察视图中。
另外,Visual Studio 没有通过将鼠标悬停在代码中的名称上来显示它。
Visual Studio 2022 具有相同的行为。

这是一个错误还是其他什么?

c# visual-studio
1个回答
0
投票

我在VS2017和VS2022中进行了测试,结果如下:

VS2017: enter image description here

VS2022: enter image description here

VS2017确实存在你提到的问题,但VS2022无论你将鼠标悬停还是在Watch窗口中都可以正常显示LocalEps值。毕竟VS2017是很多年前的产品了,缺少一些功能也很正常。建议您使用最新版本的VS2022。

© www.soinside.com 2019 - 2024. All rights reserved.