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
"." custom specifier in C#
The "." custom format specifier adds a localized decimal separator into the output string.
The 1st period in the format string determines the location of the decimal separator in the formatted value.
double d = 2.3;
d.ToString("0.00", CultureInfo.InvariantCulture
Let us see another example to learn how to implement “.” Custom specifier.
Example
using System;
using System.Globalization;
class Demo {
static void Main() {
double d;
d = 3.7;
Console.WriteLine(d.ToString("0.00", CultureInfo.InvariantCulture));
Console.WriteLine(String.Format(CultureInfo.InvariantCulture, "{0:0.00}", d));
d = 5.89;
Console.WriteLine(d.ToString("00.00", CultureInfo.InvariantCulture));
Console.WriteLine(String.Format(CultureInfo.InvariantCulture, "{0:00.00}", d));
}
}
Output
3.70 3.70 05.89 05.89
Advertisements
