C
C#2y ago
khamas

force 'normal' standards for parsing decimal numbers from string

I want to force my ASP.NET API to parse numbers as '102.28', currently it throws an error because it expects the format with a comma: '102,28'
7 Replies
mtreit
mtreit2y ago
Use the overload that takes an IFormatProvider
khamas
khamas2y ago
yes but, I am accepting the decimal as a form value how can I force a global culture?
mtreit
mtreit2y ago
I don't know what this means Are you calling Decimal.Parse?
khamas
khamas2y ago
[FromForm] decimal value in asp.net web api
mtreit
mtreit2y ago
Ok I have no idea how that works
khamas
khamas2y ago
ok np, thanks anyways @mtreit I needed to set CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; in Program.cs before anything else wait actually, it did not work :((((