It seems that you can only have one "NumberDecimalSeparator" at a
time, so you need two calls to TryParse (there must be a better way?):
private static bool TryParse(string str, out double d)
{
// leave the CurrentCulture in its original state
CultureInfo culture = CultureInfo.CurrentCulture.Clone()
as CultureInfo;
foreach (string separator in new string[]{ ",", "."})
{
culture.NumberFormat.NumberDecimalSeparator =
separator;
if (Double.TryParse(str,
NumberStyles.AllowDecimalPoint, culture, out d))
return true;
}
d = 0;
return false;
}
|