[Solved] Index out of bounds in an if statement [closed]


Presumably rhs is empty, and so rhs[0] does not exist. Hence an index out of bounds exception is thrown.

Try

if(!String.IsNullOrEmpty(rhs) && rhs[0] == '+')
... 

3

solved Index out of bounds in an if statement [closed]