C# Exponential (“E”) Format Specifier

CsharpProgrammingServer Side Programming

The ("E") format specifier converts a number to a string of the following form −

"-d.ddd…E+ddd"

Or

"-d.ddd…e+ddd"

Above, "d" is a digit (0-9).

Prefix the exponent with an "E" or an "e".

Example

 Live Demo

using System;
using System.Globalization;
class Demo {
   static void Main() {
      double d = 3452.7678;
      Console.WriteLine(d.ToString("E", CultureInfo.InvariantCulture));
      Console.WriteLine(d.ToString("E10", CultureInfo.InvariantCulture));
      Console.WriteLine(d.ToString("e", CultureInfo.InvariantCulture));
      Console.WriteLine(d.ToString("e10", CultureInfo.InvariantCulture));
   }
}

Output

3.452768E+003
3.4527678000E+003
3.452768e+003
3.4527678000e+003
raja
Published on 11-Sep-2018 13:22:03

Advertisements