Check the sequence of A , B in both Strings str1 and str2
foreach ( char c in str1 . ToCharArray ( ) ) { if ( c != ' C ' ) { s1 += c ; } } foreach ( char c in str2 . ToCharArray ( ) ) { if ( c != ' C ' ) { s2 += c ; } }