I have a string:
string test = “19,95”;
and I wan’t to convert it to an int.
I use:
int num = Convert.Int32(test);
However it throws an FormatException. And tells me that the string is not a proper string for conversion.
My guess is that it has to do with the decimal seperator.
How do i work around this?
Tested & working.
For completeness:
[Update]
As Rushyo correctly pointed out in my comments below, this example is contrived and the best practice approach is to identify which culture you are working with in order to get the correct CultureInfo object to work off of.
You can then utilize the localized NumberFormatInfo from that specific CultureInfo when doing all your numeric formatting.