如果以下字符串中的任何一个出现在格式字符串中,且后跟至少一个零,则该数字将在数字和指数之间使用“ E”或“ e”进行格式化。
"E" "E+" "E-" "e" "e+" "e-"
using System; using System.Globalization; class Demo { static void Main() { double num = 9400; Console.WriteLine(num.ToString("0.###E+0", CultureInfo.InvariantCulture)); Console.WriteLine(String.Format(CultureInfo.InvariantCulture, "{0:0.###E+0}", num)); Console.WriteLine(num.ToString("0.###E+000", CultureInfo.InvariantCulture)); Console.WriteLine(String.Format(CultureInfo.InvariantCulture, "{0:0.###E+000}", num)); } }
输出结果
9.4E+3 9.4E+3 9.4E+003 9.4E+003