I can't get the decimal.TryParse method to work for currency with the euro symbol. I've tried placing the symbol at the end and after a space to no avail. I've also tried different cultures ("fr-FR", "de-DE") and number styles ("Any" combines them all except hexadecimal). The method fails despite the culture showing a matching currency symbol. Parse value with Currency symbol SO solution does not work.
using System;
using System.Globalization;
public class Program
{
public static void Main()
{
var value = "€5,432,109.876";
var cultureInfo = CultureInfo.CreateSpecificCulture("de-DE");
decimal result;
if (!decimal.TryParse(value, NumberStyles.Any, cultureInfo, out result))
{
Console.WriteLine(string.Format("Unable to parse '{0}' as a number using the '{1}' culture with currency symbol '{2}'.", value, cultureInfo.IetfLanguageTag, cultureInfo.NumberFormat.CurrencySymbol));
return;
}
Console.WriteLine(result.ToString(cultureInfo));
}
}
Here's a fiddle with the above.
UPDATE
IMHO the suggested .NET: Parsing localized currency and the other one I looked into don't expand on how the root of the problem is that the culture must match all aspects of the numeric format--thanks to @Zero0 and @Dai for expanding as much on the comments and accepted answer.
Not that it wasn't ignorance of other currency formats on my part, but to see the question down-voted hints at little tolerance for error in this space. I'll keep the question posted given I found value in the answer and comments--others might as well.