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

 Live Demo

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

Samual Sam
Samual Sam

Learning faster. Every day.

Updated on: 23-Jun-2020

24K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements