Advertisement
Fhernd

CadenasCaracteresPersonalizadasNumeros.cs

Jul 17th, 2016
1,153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.14 KB | None | 0 0
  1. // Placeholder numérico: #
  2. Console.WriteLine(12.345.ToString(".##"));
  3. Console.WriteLine(12.345.ToString(".####"));
  4.  
  5. // Placeholder con cero:
  6. Console.WriteLine(12.345.ToString(".00"));
  7. Console.WriteLine(12.345.ToString(".0000"));
  8.  
  9. // Separador de grupos: ,
  10. Console.WriteLine(1234.ToString("#,###,###"));
  11. Console.WriteLine(1234.ToString("0,000,000"));
  12.  
  13. // Multiplicador: ,
  14. Console.WriteLine(1000000.ToString("#,"));
  15. Console.WriteLine(1000000.ToString("#,,"));
  16.  
  17. // Notación porcentual: ,
  18. Console.WriteLine(0.6.ToString("00%"));
  19.  
  20. // Notación exponencial:
  21. Console.WriteLine(1234.ToString("0E0"));
  22. Console.WriteLine(1234.ToString("0E+0"));
  23. Console.WriteLine(1234.ToString("0.00E00"));
  24. Console.WriteLine(1234.ToString("0.00e00"));
  25.  
  26. // Carácter de escape: \
  27. Console.WriteLine(50.ToString(@"\#0"));
  28.  
  29. // Cadena literal con comillas: 'xx' 'xx'
  30. Console.WriteLine(50.ToString("0 '...'"));
  31.  
  32. // Separador de sección: ;
  33. Console.WriteLine(15.ToString("#;(#);cero"));
  34. Console.WriteLine((-15).ToString("#;(#);cero"));
  35. Console.WriteLine(0.ToString("#;(#);cero"));
  36.  
  37. // Cualquier otro carácter:
  38. Console.WriteLine(35.2.ToString("$0 . 00c"));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement