Parse any currency to decimal
I'm trying to parse any currency like Dollar, Euro and Yen to double for
instance, and the US dollar is being parsed correctly, but the Yen and
Euro are not being parsed using this code.
double _amount;
bool _isParsed= double.TryParse("(¥123,45)", NumberStyles.Any, null, out
_amount);
The US Dollar works and is parsed into -12345.0:
double _amount;
bool _isParsed= double.TryParse("($123,45)", NumberStyles.Any, null, out
_amount);
I'm trying not to set the specific culture, because I will be parsing many
different currencies into a decimal.
I'm trying to find whether a string is actually a number (including
dollars, yens, euros, etc.)
How do I write a code that can parse any numbers including currencies in
yen, euro and what have you into a decimal?
No comments:
Post a Comment