I want to format an int as a currency in C#, but with no fractions. For example, 100000 should be "$100,000", instead of "$100,000.00" (which 100000.ToString("C") gives).
I know I can do this with 100000.ToString("$#,0"), but that's $-specific. Is there a way to do it with the currency ("C") formatter?
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.
CurrentCulture handles dates,currencies,sorting and formatting issues in Dot Net.
Use format "C0".
Possible to use n0 which provide commas like 1,234. Currency sign won't be there
try
using System.Globalization
@string.Format(new CultureInfo("en-IN"), "{0:c}", moneyvalue)
wil show the format in Rs.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With