float.TryParse issue

float totalXP = float.TryParse(problem.Split(new char[]{'+'})[1].Split(new char[]{'='})[1], out xtoFloat);

getting this error

Assets/Resources/LoginHandler.cs(80,23): error CS0029: Cannot implicitly convert type `bool' to `float'

Have you tried to cast it? like:

float totalXP = float.TryParse(problem.Split(new char[]{'+'})[1].Split(new char[]{'='})[1], out xtoFloat) as float;

(not sure if it’ll actually work)

just looking at the docs. TryParse returns a bool. I think you may want float.Parse ()

Float.TryParse returns a bool, and you are trying to store that value in a float. That is the cause of the compiler error you are seeing.

The result of the operation actually ends up in the last parameter of the TryParse function. I would do something like this:

float parsedResult;
bool success = float.TryParse(problem.Split(newchar[]{'+'})[1].Split(newchar[]{'='})[1], out parsedResult);

The resulting parsed float would now exist within the parsedResult variable.