fork(1) download
  1. using System;
  2. using System.Globalization;
  3. using System.Linq;
  4. using System.Collections.Generic;
  5.  
  6. public class Test
  7. {
  8.  
  9.  
  10. public static void Main()
  11. {
  12. currencyTest("56789");
  13. currencyTest("56789.73");
  14. currencyTest("56789.00");
  15. currencyTest("56789.7345");
  16. }
  17.  
  18. private static void currencyTest(string txt) {
  19. Decimal currency = Convert.ToDecimal(txt, new CultureInfo("en-US"));
  20. string money = currency.ToString("C");
  21.  
  22. if (currency % 1 == 0) {
  23. money = money.Substring(0, money.Length - 3);
  24. }
  25.  
  26. Console.WriteLine(money);
  27. }
  28. }
Success #stdin #stdout 0.04s 34008KB
stdin
Standard input is empty
stdout
$56,789
$56,789.73
$56,789
$56,789.73