Question

today iv notice that all the place that im using decimal first thing is in the grid show comma instead of point the second problame is when i edit or insert number with point it ignore the point

like i enterd "2.5" i got it as 25

thats like example code:

decimal a = Convert.ToDecimal("2.5");

the resoult of a is 25.

this problame is happening on the iis and also in my local machine.

it all over the place , how can i fix it ?

Was it helpful?

Solution

You can probably fix it by changing your default culture, or by forcing the use of a specific culture in the conversion calls (a).

Our wonderful, yet somehow slightly disturbing European cousins have gotten the decimal point and comma mixed up at some point in the past, so that thirty-five-thousand-and-seven-point-two-five is written as:

35.007,25

So what's almost certainly happening is that your culture settings are throwing away the thousands separator (regardless of where they are) so that "2.5" is 25. This means that a number like two-and-half-thousand (2,500) would almost certainly become two-and-a-half.


(a): In fact, you probably shouldn't force a specific culture in the conversion call, since the whole point of cultures is to adapt to people's needs. The Europeans thinks little enough of US bods already without giving them more reasons :-) What you're seeing is exactly what's supposed to be happening.

If you need a specific culture, configure your machine that way, and let your code use the default.

OTHER TIPS

What culture are you currently on? This should do the work:

decimal a = Convert.ToDecimal("2.5", new CultureInfo("en-US"));

Also, for the comma showing:

string s = a.ToString(new CultureInfo("en-US"));
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top