Tutorialspoint

1 Answer
Samual Sam
, 6 Views

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

Advertisements