[英]Display double in immediate window different in vs2013/vs2017
I have the following line of code: 我有以下代码行:
double r = 0.000056262413896897934;
In visual studio 2013, I go to the immediate windows and type: 在Visual Studio 2013中,我转到即时窗口并键入:
?r
And the results display the double's value: 结果显示了double的值:
0.000056262413896897934
However if I bring up the project in Visual Studio 2017 and type this in the immediate window: 但是,如果我在Visual Studio 2017中调出项目并在立即窗口中键入以下内容:
?r
It display the following result (exponential format): 它显示以下结果(指数格式):
5.6262413896897934E-05
I would like Visual Studio 2017 to display the format in the same way as Visual Studio 2013 does: 我希望Visual Studio 2017以与Visual Studio 2013相同的方式显示格式:
0.000056262413896897934
Not just for this variable or this solution but as a permanent setting. 不仅针对此变量或此解决方案,还作为永久设置。 Does anyone know how to do this?
有谁知道如何做到这一点? Thanks in advance
提前致谢
As @Amy mentioned you can use DebuggerDisplay
to change the appearance of an object in the debugger. 正如@Amy提到的,您可以使用
DebuggerDisplay
来更改调试器中对象的外观。 As double
is a built in type you can't just change its implementation. 由于
double
是内置类型,您不能仅更改其实现。 For cases like this the debugger has a feature where it will load in DebuggerDisplay
implementations externally that are implemented in autoexp.cs
对于这种情况,调试器具有一项功能,可以在
autoexp.cs
实现的外部DebuggerDisplay
实现中autoexp.cs
autoexep.cs
file which should be in a directory that looks like: C:\\Program Files (x86)\\Microsoft Visual Studio\\16\\Preview\\Common7\\Packages\\Debugger\\Visualizers\\Original
obviously that will change with your VS version but if you search for autoexp.cs
you'll find it. autoexep.cs
文件,该文件应该位于以下目录中: C:\\Program Files (x86)\\Microsoft Visual Studio\\16\\Preview\\Common7\\Packages\\Debugger\\Visualizers\\Original
显然该更改VS版本,但如果搜索autoexp.cs
,则会找到它。 [assembly: DebuggerDisplay(@"{ToString(""F17""),nq}", Target = typeof(Double))]
that's going to tell the debugger to basically execute ToString("F17")
whenever it's displaying a double
. [assembly: DebuggerDisplay(@"{ToString(""F17""),nq}", Target = typeof(Double))]
,这将告诉调试器基本上执行ToString("F17")
只要它显示double
。 autoexp.cs
is eg C:\\Program Files (x86)\\Microsoft Visual Studio\\16\\Preview\\Common7\\Packages\\Debugger\\Visualizers\\Original
autoexp.cs
所在的autoexp.cs
,例如C:\\Program Files (x86)\\Microsoft Visual Studio\\16\\Preview\\Common7\\Packages\\Debugger\\Visualizers\\Original
csc /t:library autoexp.cs
csc /t:library autoexp.cs
构建文件 You should then see something like: 你应该看到类似的东西:
More info on DebuggerDisplay
is in our docs over at: https://docs.microsoft.com/en-us/visualstudio/debugger/using-the-debuggerdisplay-attribute?view=vs-2017 and more info on the ToString
implementation for Double
is over at: https://docs.microsoft.com/en-us/dotnet/api/system.double.tostring?view=netframework-4.7.2 . 有关
DebuggerDisplay
更多信息,请访问我们的文档, 网址为: https : //docs.microsoft.com/zh-cn/visualstudio/debugger/using-the-debuggerdisplay-attribute? ToString
以及有关ToString
实现的更多信息Double
结束于: https : //docs.microsoft.com/zh-cn/dotnet/api/system.double.tostring?view=netframework-4.7.2 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.