You are reassigning the value of xtop
twice when you use it as the out
argument for TryParse
. The second time you put it as the out
argument is where it becomes 0.5
and so checkx <= xtop
becomes false.
if (decimal.TryParse(inputy, out xtop))
When you use out
it means that you are going to assign that value.