Remove odd indexed characters from a given string | C # program to implement the above approach ; Function to remove odd indexed characters from a given string ; Stores the resultant string ; If the current index is odd ; Skip the character ; Otherwise , append the character ; Return the modified string ; Driver Code ; Remove the characters which have odd index
using System ; class GFG { static string removeOddIndexCharacters ( string s ) { string new_string = " " ; for ( int i = 0 ; i < s . Length ; i ++ ) { if ( i % 2 == 1 ) continue ; new_string += s [ i ] ; } return new_string ; } public static void Main ( ) { string str = " abcdef " ; str = removeOddIndexCharacters ( str ) ; Console . Write ( str ) ; } }