How to detect if string is currency in c#
问题 Usually when I have need to convert currency string (like 1200,55 zł or $1,249) to decimal value I do it like this: if (currencyString.Contains("zł)) { decimal value = Decimal.Parse(dataToCheck.Trim(), NumberStyles.Number | NumberStyles.AllowCurrencySymbol); } Is there a way to check if string is currency without checking for specific currency? 回答1: If you just do the conversion (you should add | NumberStyles.AllowThousands | NumberStyles.AllowDecimalPoint as well) then if the string contains