Google 通讯录中的不同域
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));
在上面的代码中,我试图获取电子邮件 ID 的不同域,但我得到了它们,我的逻辑有什么问题吗?
测试数据:
inp:
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
... 这样 20,000 个条目
我需要获得
DISTINCT
域,但我的 O/P
gmail.com
yahoo.com
gmail.com
gmail.com
someOtherDomain.com
实际上应该是:
gmail.com 雅虎网站 一些其他域名.com
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 above code, i am trying to get distinct domain of email id, but i am getting them all whats problem with my logic?
test data:
inp:
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
...
such 20,000 entries
i need to get DISTINCT
domains
but my o/p is
gmail.com
yahoo.com
gmail.com
gmail.com
someOtherDomain.com
actually it should be:
gmail.com
yahoo.com
someOtherDomain.com
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这里到底出了什么问题并不明显,但这是一种低效且丑陋的做法。我建议你试试这个:
话虽如此,你原来的代码确实应该可以工作。您能提供一些失败的测试数据吗?
It's not obvious what's actually wrong here, but it's an inefficient and ugly way of doing it. I suggest you try this:
Having said that, your original code really should have worked. Could you provide some test data which is failing?