Remove consecutive alphabets which are in same case | C # program to remove the consecutive characters from a string that are in same case ; Function to return the modified string ; Traverse through the remaining characters in the string ; If the current and the previous characters are not in the same case then take the character ; Driver code
using System ; class GFG { static string removeChars ( string s ) { string modifiedStr = " " ; modifiedStr += s [ 0 ] ; for ( int i = 1 ; i < s . Length ; i ++ ) { if ( char . IsUpper ( s [ i ] ) && char . IsLower ( s [ i - 1 ] ) || char . IsLower ( s [ i ] ) && char . IsUpper ( s [ i - 1 ] ) ) modifiedStr += s [ i ] ; } return modifiedStr ; } public static void Main ( ) { string s = " GeeksForGeeks " ; Console . Write ( removeChars ( s ) ) ; } }