List<string> ls = new List<string>();
Feed<Contact> f = cr.GetContacts();
foreach (Contact e in f.Entries)
foreach (EMail el in e.Emails)
if (!(ls.Contains(el.Address.Substring(el.Address.LastIndexOf('@')+1))))
ls.Add(el.Address.Substring(el.Address.LastIndexOf('@')+1));
In the above code, I'm trying to get a separate email id domain, but I get them all, what's the problem with my logic?
test data:
in:
abca@gmail.com
sdafdf@yahoo.com
sdfs@gmail.com
ssdf@gmail.com
sdfsf@someOtherDomain.com
... such 20,000 entries
I need to get DISTINCTdomains
but my o / p
gmail.com
yahoo.com
gmail.com
gmail.com
someOtherDomain.com
in fact it should be:
gmail.com yahoo.com someOtherDomain.com
source
share