- 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# Currency ("C") Format Specifier
The "C" (or currency) format specifier is used to convert a number to a string representing a currency amount.
Let us see an example.
double value = 139.87;
Now to display the above number until three decimal places, use (“C3”) currency format specifier.
value.ToString("C3", CultureInfo.CurrentCulture)
Let us see another example.
Example
using System; using System.Globalization; class Demo { static void Main() { double value = 234.66; // displays $ Console.WriteLine(value.ToString("C", CultureInfo.CurrentCulture)); Console.WriteLine(value.ToString("C3", CultureInfo.CurrentCulture)); } }
Output
$234.66 $234.660
Advertisements