- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
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