次の簡単なプログラムをデバッグしてみて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
}
}
したがって、VSには独自の方法でを表示するようSystem.Double
です。この目的のためにどのメソッドを呼び出しますか?プログラムでまったく同じ文字列表現を取得する方法はありますか?
(これをVisual Studio 2010 Professionalで試してみました。)