Traverse the equation
for ( int j = 0 ; j < n ; j ++ ) { if ( equation [ j ] == ' + ' equation [ j ] == ' - ' ) { if ( j > i ) total += sign * Int32 . Parse ( equation . Substring ( i , j - i ) ) ; i = j ; }