C
C#3y 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
mtreit3y ago
Use the overload that takes an IFormatProvider
khamas
khamasOP3y ago
yes but, I am accepting the decimal as a form value how can I force a global culture?
mtreit
mtreit3y ago
I don't know what this means Are you calling Decimal.Parse?
khamas
khamasOP3y ago
[FromForm] decimal value in asp.net web api
mtreit
mtreit3y ago
Ok I have no idea how that works
khamas
khamasOP3y 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 :((((
Want results from more Discord servers?
Add your server