/// <summary> /// Moves duplicates from _outlookContacts to _outlookContactDuplicates /// </summary> private void FilterOutlookContactDuplicates() { _outlookContactDuplicates = new Collection <Outlook.ContactItem>(); if (_outlookContacts.Count < 2) { return; } Outlook.ContactItem main, other; bool found = true; int index = 0; while (found) { found = false; for (int i = index; i <= _outlookContacts.Count - 1; i++) { main = _outlookContacts[i] as Outlook.ContactItem; // only look forward for (int j = i + 1; j <= _outlookContacts.Count; j++) { other = _outlookContacts[j] as Outlook.ContactItem; if (other.FileAs == main.FileAs && other.Email1Address == main.Email1Address) { _outlookContactDuplicates.Add(other); _outlookContacts.Remove(j); found = true; index = i; break; } } if (found) { break; } } } }