Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Selected Reading
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
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
Advertisements
