fork(1) download
  1. using static System.Console;
  2. using static System.Convert;
  3. using static System.Math;
  4. using System.Globalization;
  5.  
  6. public class Program {
  7. public static void Main() {
  8. if (!decimal.TryParse("5.541,88", NumberStyles.Currency, CultureInfo.CreateSpecificCulture("pt-BR"), out var valor)) WriteLine("Formato inválido para conversão");
  9. WriteLine($"Decimal: {valor}");
  10. WriteLine($"Inteiro: {ToInt32(valor)}");
  11. WriteLine($"Inteiro truncado: {Truncate(valor)}");
  12. WriteLine($"Decimal truncado: {decimal.Truncate(valor)}");
  13. }
  14. }
  15.  
  16. //https://pt.stackoverflow.com/q/498491/101
Success #stdin #stdout 0.02s 16624KB
stdin
Standard input is empty
stdout
Decimal: 5541.88
Inteiro: 5542
Inteiro truncado: 5541
Decimal truncado: 5541