Hallo und
Hier eine mögliche Lösung
C#-Quelltext
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21:
| public List<string> SearchDoubleWords(List<string> myList) { List<string> wordList = new List<string>(); List<string> doubleWordList = new List<string>(); foreach (string word in myList) { if (wordList.Contains(word)) { if (!doubleWordList.Contains(word)) doubleWordList.Add(word); } else wordList.Add(word); } return doubleWordList; } |
EDIT: Ich hoffe, dir jetzt nicht das Vergnügen am Selbst-Ausprobieren genommen zu haben. Dachte, dass hilft dir vielleicht beim verstehen.