fork download
  1. using static System.Console;
  2. public class Program {
  3. public static void Main() => WriteLine(Valor.Arredondar(123.456M, 2));
  4. }
  5.  
  6. public static class Valor {
  7. public static decimal Arredondar(decimal valor, int casasDecimais) => decimal.Round(valor, casasDecimais);
  8.  
  9. public static decimal? Arredondar(decimal? valor, int casasDecimais) {
  10. if (valor == null) return null;
  11. return Arredondar(valor.Value, casasDecimais);
  12. }
  13. }
  14.  
  15. //https://pt.stackoverflow.com/q/104297/101
Success #stdin #stdout 0.02s 16612KB
stdin
Standard input is empty
stdout
123.46