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


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

Updated on: 23-Jun-2020

266 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements