using System.Globalization;
using static System.Console;
public static void Main()
WriteLine("Valor: {0}", StrCurrencyToDecimal("R$3.852,00"));
WriteLine("Valor: {0}", StrCurrencyToDecimal("R$0,00"));
WriteLine("Valor: {0}", StrCurrencyToDecimal("R$-3.852,00"));
WriteLine("Valor: {0}", StrCurrencyToDecimal(""));
WriteLine("Valor: {0}", StrCurrencyToDecimal("R3.852,00"));
WriteLine("Valor: {0}", StrCurrencyToDecimal("$3.852,00"));
WriteLine("Valor: {0}", StrCurrencyToDecimal("3.852,00"));
WriteLine("Valor: {0}", StrCurrencyToDecimal("R$3ad.852,00"));
WriteLine("Valor: {0}", StrCurrencyToDecimal("R$3,852.00"));
WriteLine("Valor: {0}", StrCurrencyToDecimal("assR$3,852.00"));
static decimal StrCurrencyToDecimal(string str)
NumberFormatInfo infoCurrency = new NumberFormatInfo();
infoCurrency.NegativeSign = "-";
infoCurrency.CurrencyDecimalSeparator = ",";
infoCurrency.CurrencyGroupSeparator = ".";
infoCurrency.CurrencySymbol = "R$";
if (decimal.TryParse(str, NumberStyles.Currency, infoCurrency, out var result))