text: String containing first letter of every word in a given string with spaces | C # program to find the string which contain the first character of each word of another string . ; Function to find string which has first character of each word . ; Traverse the string . ; If it is space , set v as true . ; Else check if v is true or not . If true , copy character in output string and set v as false . ; Driver code
code: using System ; class GFG { static String firstLetterWord ( String str ) { String result = " " ; bool v = true ; for ( int i = 0 ; i < str . Length ; i ++ ) { if ( str [ i ] == ' ▁ ' ) { v = true ; } else if ( str [ i ] != ' ▁ ' && v == true ) { result += ( str [ i ] ) ; v = false ; } } return result ; } public static void Main ( ) { String str = " geeks ▁ for ▁ geeks " ; Console . WriteLine ( firstLetterWord ( str ) ) ; } }