Advertisement
Guest User

Untitled

a guest
Aug 20th, 2017
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.65 KB | None | 0 0
  1. static string CommonCharacters(string str1, string str2)
  2.         {
  3.             var ListofCommonCharactersAlreadyIncluded = new List<char>();
  4.             string commoncharacters = "";
  5.             for (int i = 0; i < str1.Length; i++)
  6.             {
  7.                 for (int j = 0; j < str2.Length; j++)
  8.                 {
  9.                     if((str1[i]==str2[j])&&(!ListofCommonCharactersAlreadyIncluded.Contains(str1[i])))
  10.  
  11.                     {
  12.                         commoncharacters += str1[i] + " ";
  13.                         ListofCommonCharactersAlreadyIncluded.Add(str1[i]);
  14.  
  15.                     }
  16.  
  17.  
  18.                 }
  19.             }
  20.  
  21.  
  22.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement