I'm having trouble with this. I've tried float.Parse, float.TryParse and parseFloat.
string =currentValue= "";
currentValue = dataIn.Substring(0,currentChar);
rbValues[currentRB,currentParam] = float.TryParse(currentValue);
When I do float.TryParse(currentValue) it says error CS1501: "No overload for method 'TryParsee' takes '1' arguments
When I do float.Parse or parseFloat() or Double.Parse (it's the same for float) it says FormatException: Invalid Format.
System.Double.Parse(System.String s, NumberStyles style, IFormatProvider provider)
I've seen plenty of examples where people have used one or the other method and it works, but none of them seem to work for me. What's going wrong here?
Well, there seems to be two immediate oddities here, and then assuming your currentValue is a valid (float) string we'll see about using another format provider.
string = currentValue = ""; looks very odd. string currentValue = ""; is the proper way.
- The error says TryParsee but in your sample code you have written float.TryParse. Are you sure you ain't dealing with a typo somewhere? It should be TryParse, not TryParsee. Also, it requires more than one argument, see below.
- Floats can be formatted 3.14 or 3,14 and it's a difference right there. Use a proper format provider to parse your string. The link contain example code.
Also, I see you're not passing the required arguments to float.TryParse and store the success of the parse in rbValues (it return true if it could parse and false otherwise). What I guess you want to do is:
if (float.TryParse(currentValue, out result))
rbValues[currentRB, currentParam] = result;
And don't forget the format provider which was excluded from this example.