Friday, February 12, 2010

"Input string was not in a correct format" - Exception when Parsing strings to float, double

When developing the Abey Limousines Management System for Monaco France we encountered a strange error from both from parsing a string to double or a float, The application worked fine in our environment and it didn’t parse accurately in the client environment.

The problem was in Sri Lanka we use dot(.) as the decimal symbol and in Monaco France they use comma(,) as the decimal symbol, we had a text box to show their tax rate as 5.5, When parsing this 5.5 string to float or double both float.Parse() and float.TryParse() methods throws a exception saying “Input string was not in a correct format”

We Multisoft Extreme was able to successfully solve that problem by changing the decimal symbol from dot(.) to comma(,) in every occurrence of the application and changing 5.5 to 5,5. Also most importantly changing our current format to French (Monaco) from the Regional and Language Options form the control panel.

No comments:

Post a Comment