Visual Studio在调试期间如何显示System.Double?

Jep*_*sen 7 c# debugging double visual-studio-2010

尝试调试以下简单程序,并x在每个步骤中鼠标悬停(或"添加监视" x或其他).

using System;
using System.Globalization;

static class Program
{
  static double x;

  static void Main()
  {
    x = 2d;

    // now debugger shows "2.0", as if it has used
    // x.ToString("F1", CultureInfo.InvariantCulture)

    x = 8.0 / 7.0;

    // now debugger shows "1.1428571428571428", as if it had used
    // x.ToString("R", CultureInfo.InvariantCulture)
    // Note that 17 significant figures are shown, not the usual 15.

    x = -1e-200 / 1e200;

    // now debugger shows "0.0"; there is no indication that this is really negative zero
    //

    Console.WriteLine(1.0 / x); // this is negative infinity
  }
}
Run Code Online (Sandbox Code Playgroud)

所以,显然VS有自己的显示方式System.Double.它为此目的采用了哪种方法?有没有办法可以通过编程方式获得完全相同的字符串表示?

(使用Visual Studio 2010 Professional尝试过这一点.)

Jar*_*Par 8

C#和VB.Net EE的核心是将_ecvt_s函数格式化double为字符串.

两者都对结果字符串进行了一些清理,以使显示更多C#和VB之类,并处理一些角点情况更好一些.无论是_ecvt_s功能或清理代码可能是负责看到的差异.很难一目了然

有些人可能会问为什么我们会经历所有这些麻烦而不是只是调用ToString值并显示它.有几个原因我们不这样做.

首先,功能评估甚至ToString是EE可以采取的最昂贵的行动.常见真实情景的概况表明,我们98%以上的时间花在了功能评估上.任何时候我们都可以避免使用功能因为性能影响.

第二个原因很简单,功能评估并不总是可用的.这里有很多情形下,函数计算是不可用但人们仍然希望看到的原始类型的显示器等double,int等......以他们离开将基本上杀死调试经验.因此我们需要在没有ToString支持的情况下 解决这个问