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
C# Fixed-Point (“F”) Format Specifier
The ("F") format specifier converts a number to a string of the following form −
"-ddd.ddd…"
Above, "d" indicates a digit (0-9).
Let us see an example.
Here, if we will set (“F3”) format specifier to add three values after decimal places, for let’s say, 212.
212.000
The following is another example −
Example
using System;
using System.Globalization;
class Demo {
static void Main() {
int val;
val = 38788;
Console.WriteLine(val.ToString("F",CultureInfo.InvariantCulture));
val = -344;
Console.WriteLine(val.ToString("F3",CultureInfo.InvariantCulture));
val = 5656;
Console.WriteLine(val.ToString("F5",CultureInfo.InvariantCulture));
}
}
Output
38788.00 -344.000 5656.00000
Advertisements
