The way floating-point values (float
, double
, decimal
) are displayed are heavily dependent on locale.
Some locales use ,
as decimal-separator, some use .
.
There are multiple ways to solve your problem. If this is the only place in which you want to display decimals with a .
, rather than a ,
, then i would recommend using .ToString()
with a custom format (or locale)
Example
<td>@Model.ActualExpenceEntry.Allowance.ToString("0.##")</td>
This will use the current threads culture.
Using the InvariantCulture
, will also display the number with a .
as decimal-separator.
<td>@Model.ActualExpenceEntry.Allowance.ToString(CultureInfo.InvariantCulture)</td>
Another way to solve the problem is to change the culture for the project globally, this however might for instance mess up number parsing and "print-outs".
For instance, for Double.Parse()
will ignore ,
and parse "1,5"
to 15
. Which might be an easy thing to overlook.
@Gurgen_Sargsyan provided an example on how to do this via web.config
it's depend on client culture, use configuration to solve it.
<system.web>
<globalization culture="xx-XX" uiCulture="xx-XX" />
</system.web>
Where xx-XX is a valid cutlure, for instance en-GB
, or en-US
. Leaving it empty will cause your application to fall back on InvariantCulture
.