String format

Hi

i need to read from a TextBox in a float

the problem is the format : if i use "," like : 12,5 it works but it dosn't work for "." like 12.5

the code i use is :

float x;

x = float.Parse(textBox2.Text);





Answer this question

String format

  • Brad Smith

    You can parse with a specific culture if you want, use the code like this:


    CultureInfo cultureInfo = CultureInfo.CreateSpecificCulture("nl-NL");
    float x = float.Parse(textBox2.Text, NumberStyles.Any, cultureInfo);



  • String format