Print all the non | C # program to print all the non - repeating words from the two given sentences ; Function to print all the non - repeating words from the two given sentences ; Concatenate the two Strings into one ; Iterating over the whole concatenated String ; Searching for the word in A . If while searching , we reach the end of the String , then the word is not present in the String ; Initialise word for the next iteration ; Driver code
using System ; class GFG { static void removeRepeating ( string s1 , string s2 ) { string s3 = s1 + " ▁ " + s2 + " ▁ " ; string words = " " ; int i = 0 ; foreach ( char x in s3 . ToCharArray ( ) ) { if ( x == ' ▁ ' ) { if ( ! s1 . Contains ( words ) || ! s2 . Contains ( words ) ) Console . Write ( words ) ; words = " ▁ " ; } else { words = words + x ; } } } public static void Main ( string [ ] args ) { string s1 = " I ▁ have ▁ go ▁ a ▁ pen " ; string s2 = " I ▁ want ▁ to ▁ go ▁ park " ; removeRepeating ( s1 , s2 ) ; } }