Here is basically the code I have :
string text = "-0.05537987";
float value = Single.Parse(text);
When I try and parse a negative number like I did here I get "Input string was not in the correct format."
Here is basically the code I have :
string text = "-0.05537987";
float value = Single.Parse(text);
When I try and parse a negative number like I did here I get "Input string was not in the correct format."
Your parsing should work, I believe your current culture has a different character for decimal separator. Use CultureInfo.InvariantCulture
float value = Single.Parse(text, CultureInfo.InvariantCulture);
Your code works fine for me - https://dotnetfiddle.net/JfPfss
Use InvariantCulture and see if that is the issue:
float value = Single.Parse(text, CultureInfo.InvariantCulture);
Just use CultureInfo.InvariantCulture
string text = "-0.05537987";
float value = Single.Parse(text, CultureInfo.InvariantCulture);
MessageBox.Show("your value = "+value);