check whether s [ i ] is a character or a integer between 0 to 9 and compute its equivalent BCD
if ( s [ i ] >= 47 && s [ i ] <= 52 ) { string result = Convert . ToString ( ( int ) s [ i ] , 2 ) ; Console . Write ( result . Substring ( result . Length - 4 ) + " ▁ " ) ; } else { string result = Convert . ToString ( ( int ) s [ i ] - 55 , 2 ) ; Console . Write ( result . Substring ( result . Length - 4 ) + " ▁ " ) ; } } }