String format currency negative
C# Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
class Program { static void Main(string[] args) { //this line create a culture for english in us CultureInfo usCulture = new CultureInfo("en-US"); CultureInfo frCulture = new CultureInfo("fr-FR"); CultureInfo gbCulture = new CultureInfo("en-GB"); CultureInfo dkCulture = new CultureInfo("da-DK"); //this line create a decimal variable. decimal decimalValue = -236666.86M; Console.WriteLine("negetive decimal value: " + decimalValue); Console.WriteLine("string format currency negative sign _____________"); //format string using ToString method. Console.WriteLine("negetive currency: " + decimalValue.ToString("C")); //format string using string.format method. Console.WriteLine("\ncurrency negative sign in [en-US] culture: " + string.Format(usCulture, "{0:C}", decimalValue)); Console.WriteLine("currency negative sign in [fr-FR] culture: " + string.Format(frCulture, "{0:C}", decimalValue)); Console.WriteLine("currency negative sign in [en-GB] culture: " + string.Format(gbCulture, "{0:C}", decimalValue)); Console.WriteLine("currency negative sign in da-DK] culture: " + string.Format(dkCulture, "{0:C}", decimalValue)); Console.ReadLine(); } } |
Output:
1 2 3 4 5 6 7 8 9 10 |
negetive decimal value: -236666,86 string format currency negative sign _____________ negetive currency: -?236.666,86 currency negative sign in [en-US] culture: ($236,666.86) currency negative sign in [fr-FR] culture: -236 666,86 ? currency negative sign in [en-GB] culture: -£236,666.86 currency negative sign in da-DK] culture: -236.666,86 kr. |
C# format negative number parenthesis,
C# format currency without parentheses,,
C# string format,
C# currency format,
C# string format decimal places,
C# cultureinfo currency format,
C# int to string format,