I am making an MVC5 app using Razor.
I set the NumberFormat in my Current Culture like this:
var culture = new System.Globalization.CultureInfo(cultureName);
culture.NumberFormat.NumberGroupSizes = new int[] { 3 };
culture.NumberFormat.NumberGroupSeparator = " ";
culture.NumberFormat.NumberDecimalSeparator = ";";
Thread.CurrentThread.CurrentCulture = culture;
Thread.CurrentThread.CurrentUICulture = Thread.CurrentThread.CurrentCulture;
Then I put some property typed double in one of my views with the value 1800.01
@MyDecimalValue
And what I get is 1800;01
. What I would like to get is 1 800;01
. In order to include all the parameters I have set, I have to use something like this:
@MyDecimalValue.ToString("N")
I think that when Razor's engine turns my Razor code into HTML, it calls the ToString() method, which ignores the thousands separator I have set.
Is there any way to make Razor to render the thousands separator without calling ToStringMethod(string format) ?
Any help you can provide will be very helpful!