C# define string format of double/floats to be US english by default

Posted by neil on Stack Overflow See other posts from Stack Overflow or by neil
Published on 2010-04-12T19:05:49Z Indexed on 2010/04/12 19:13 UTC
Read the original article Hit count: 255

Filed under:
|
|
|

Hi, I have got several thousands of lines of a web application source code, initially written on a US development system, to maintain. It makes heavy use of SQL statement strings, which are combined on the fly, e.g.

string SQL = "select * from table where double_value = " + Math.Round(double_value, 2);

Don't comment on bad programming style, that doesn't help me in this case :)

The cruix: My system uses a German locale, which in turn leads to wrong SQL statements, like this:

"select * from table where double_value = 15,5"

(Note the comma as decimal separator instead of a point).

Question: What is the most "elegant" way to change the locale of the web app in this case) to US or UK in order to prevent being forced to change and inspect every single line of code? .net 3.5 is not an option (would give me the chance to overwrite ToString() in an extension class)

Kind regards

© Stack Overflow or respective owner

Related posts about c#

Related posts about double