How to print currency value in C#.Net?
C# Currency ("C") Format Specifier
To convert a number to a string we use the "C" (or currency) format specifier and it is representing a currency amount.
Let us see an example as follows.
double value = 175.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 as follows,
using System;
using System.Globalization;
class Demo {
static void Main() {
double value = 275.66;
// displays $
Console.WriteLine(value.ToString("C", CultureInfo.CurrentCulture));
Console.WriteLine(value.ToString("C3", CultureInfo.CurrentCulture));
}
}
The output of the above code is as follows:
$275.66
$275.660
Which of the following declaration is wrong?
How to use a keyword as an identifier?
Which of the following access modifier added in C# 7.2?
Which of the following keyword is quite opposite to sealed?
Which of the following notation is incorrect?