Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static string CommonCharacters(string str1, string str2)
- {
- var ListofCommonCharactersAlreadyIncluded = new List<char>();
- string commoncharacters = "";
- for (int i = 0; i < str1.Length; i++)
- {
- for (int j = 0; j < str2.Length; j++)
- {
- if((str1[i]==str2[j])&&(!ListofCommonCharactersAlreadyIncluded.Contains(str1[i])))
- {
- commoncharacters += str1[i] + " ";
- ListofCommonCharactersAlreadyIncluded.Add(str1[i]);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement