The "E" and "e" custom specifiers in C#

CsharpProgrammingServer Side Programming

If any of the following string appears in the format string and followed by at least one zero, then the number is formatted with an “E” or “e” in between the number and the exponent.

"E"
"E+"
"E-"
"e"
"e+"
"e-"

Example

 Live Demo

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));
   }
}

Output

9.4E+3
9.4E+3
9.4E+003
9.4E+003
raja
Published on 11-Sep-2018 16:29:18
Advertisements