Typecasting each character to integer and adding the digit to respective sums
Leftsum += ( int ) ( Char . GetNumericValue ( s [ i ] ) - Char . GetNumericValue ( '0' ) ) ; Rightsum += ( int ) ( Char . GetNumericValue ( s [ s . Length - 1 - i ] ) - Char . GetNumericValue ( '0' ) ) ; } if ( Leftsum == Rightsum ) Console . WriteLine ( " Balanced " ) ; else Console . WriteLine ( " Not ▁ Balanced " ) ; }