Hello. There is a form. There is a TextBox on the form, I enter 0.27 into it and get the error: invalid input string format. How to fix this error? It works with a comma, with a dot it does not want.

double X = double.Parse(previousText.ToString()); 

    1 answer 1

    Most likely, your operating system is Russified, and therefore Decimical Separator (fractional separator from the whole in decimal fraction) is set to comma. In the English versions, the point is taken as a separator.

    • Yes, and what if I need the support of both English and Russian? - Demon
    • one
      You can simply change the fractional separator in the system using the WinAPI function: SetDecimalSeparator ('.') - AseN
    • 3
      then you can use this approach: NumberFormatInfo provider = new NumberFormatInfo (); provider.NumberDecimalSeparator = "."; double X = Convert.ToDouble (previousText.ToString (), provider); Convert.ToDouble - Specter
    • @Spectre, yes, yes) - AseN