【发布时间】:2017-09-28 01:35:45
【问题描述】:
我想连接两个哈希集,但是当我使用 Linq 时,我得到一个 IEnumerable 而不是一个新的哈希集
var hashSet1 = new HashSet<string>();
hashSet1.Add("foo");
hashSet1.Add("foo1");
hashSet1.Add("foo2");
hashSet1.Add("footoexclude");
var hashSet2 = new HashSet<string>();
hashSet2.Add("fooh2");
hashSet2.Add("fooh3");
hashSet2.Add("foo2h4");
hashSet2.Add("footoexclude");
var hres = hashSet1.Union(hashSet2);
有什么解决办法吗?
【问题讨论】: