fork download
  1. using static System.Console;
  2. using static System.Math;
  3. using static System.Convert;
  4. using static System.Globalization.NumberStyles;
  5. using System.Globalization;
  6.  
  7. public class Test {
  8. public static void Main() {
  9. var x = 1.41293;
  10. WriteLine(x.ToString("N3"));
  11. WriteLine(Round(x, 3));
  12. WriteLine(Round(ToDecimal(x), 3));
  13. if (!decimal.TryParse("1,41293", Number, new CultureInfo("pt-BR"), out var numero)) return;
  14. WriteLine(Round(numero, 3));
  15. }
  16. }
  17.  
  18. //https://pt.stackoverflow.com/q/243124/101
Success #stdin #stdout 0.03s 23252KB
stdin
Standard input is empty
stdout
1.413
1.413
1.413
1.413