I have the following line of code:
double r = 0.000056262413896897934;
In visual studio 2013, I go to the immediate windows and type:
?r
And the results display the double's value:
0.000056262413896897934
However if I bring up the project in Visual Studio 2017 and type this in the immediate window:
?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:
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. As double
is a built in type you can't just change its implementation. For cases like this the debugger has a feature where it will load in DebuggerDisplay
implementations externally that are implemented in 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. [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
. autoexp.cs
is eg C:\\Program Files (x86)\\Microsoft Visual Studio\\16\\Preview\\Common7\\Packages\\Debugger\\Visualizers\\Original
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 .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.