fork download
  1. using System;
  2.  
  3. public class Test
  4. {
  5. public static void Main()
  6. {
  7. // Placeholder numérico: #
  8. Console.WriteLine(12.345.ToString(".##"));
  9. Console.WriteLine(12.345.ToString(".####"));
  10.  
  11. // Placeholder con cero:
  12. Console.WriteLine(12.345.ToString(".00"));
  13. Console.WriteLine(12.345.ToString(".0000"));
  14.  
  15. // Separador de grupos: ,
  16. Console.WriteLine(1234.ToString("#,###,###"));
  17. Console.WriteLine(1234.ToString("0,000,000"));
  18.  
  19. // Multiplicador: ,
  20. Console.WriteLine(1000000.ToString("#,"));
  21. Console.WriteLine(1000000.ToString("#,,"));
  22.  
  23. // Notación porcentual: ,
  24. Console.WriteLine(0.6.ToString("00%"));
  25.  
  26. // Notación exponencial:
  27. Console.WriteLine(1234.ToString("0E0"));
  28. Console.WriteLine(1234.ToString("0E+0"));
  29. Console.WriteLine(1234.ToString("0.00E00"));
  30. Console.WriteLine(1234.ToString("0.00e00"));
  31.  
  32. // Carácter de escape: \
  33. Console.WriteLine(50.ToString(@"\#0"));
  34.  
  35. // Cadena literal con comillas: 'xx' 'xx'
  36. Console.WriteLine(50.ToString("0 '...'"));
  37.  
  38. // Separador de sección: ;
  39. Console.WriteLine(15.ToString("#;(#);cero"));
  40. Console.WriteLine((-15).ToString("#;(#);cero"));
  41. Console.WriteLine(0.ToString("#;(#);cero"));
  42.  
  43. // Cualquier otro carácter:
  44. Console.WriteLine(35.2.ToString("$0 . 00c"));
  45. }
  46. }
Success #stdin #stdout 0.05s 23984KB
stdin
Standard input is empty
stdout
12.35
12.345
12.35
12.3450
1,234
0,001,234
1000
1
60%
1E3
1E+3
1.23E03
1.23e03
#50
50 ...
15
(15)
cero
$35 . 20c