Question

Is it possible that .NET uses on server A ',' as decimal separator and on another server B '.'? + How can you detect this?

When converting strings to doubles, on server A everything works fine, but on server B we have problems.

Example:

server A : 20,4 --> 20.4 server B : 20,4 --> 204

We would need to detect this so that on both servers things keep on working.

thx, Lieven Cardoen

Was it helpful?

Solution

Sounds like the locale is being set correctly on one server but not the other.

There are a few ways you could do this, but you might want to set the locale for the current thread in your App/ASP.NET page using Thread.CurrentThread.CurrentCulture and Thread.CurrentThread.CurrentUICulture.

To set this for the entire application, you'd do this in your web.config:

<configuration>
  <system.web>
    <globalization culture="en-US" uiCulture="en-US" />
...

OTHER TIPS

I use

String.Format(System.Globalization.CultureInfo.InvariantCulture, ....)

in those cases where you do not want to have culture specific output. (For example, when you write serialize data for other applications etc.) This way no matter what Culture is currently set, the output will always be the same.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top