text: Reverse vowels in a given string | C # program to reverse order of vowels ; utility function to check for vowel ; Function to reverse order of vowels ; Start two indexes from two corners and move toward each other ; swapping ; Driver code
code: using System ; class GFG { static Boolean isVowel ( char c ) { return ( c == ' a ' c == ' A ' c == ' e ' c == ' E ' c == ' i ' c == ' I ' c == ' o ' c == ' O ' c == ' u ' c == ' U ' ) ; } static String reverseVowel ( String str ) { int i = 0 ; int j = str . Length - 1 ; char [ ] str1 = str . ToCharArray ( ) ; while ( i < j ) { if ( ! isVowel ( str1 [ i ] ) ) { i ++ ; continue ; } if ( ! isVowel ( str1 [ j ] ) ) { j -- ; continue ; } char t = str1 [ i ] ; str1 [ i ] = str1 [ j ] ; str1 [ j ] = t ; i ++ ; j -- ; } String str2 = String . Join ( " " , str1 ) ; return str2 ; } public static void Main ( String [ ] args ) { String str = " hello ▁ world " ; Console . WriteLine ( reverseVowel ( str ) ) ; } }