Concat HashSet <String>和IList <String>

M.S*_*.S. 5 c#

我有一个哈希集:

HashSet<String> hash ;
Run Code Online (Sandbox Code Playgroud)

和列表:

IList<String> names = new List<String>(){"ABC","DEF"};
Run Code Online (Sandbox Code Playgroud)

我想连接哈希和名字; 然后将结果存储在相同的变量中,即散列.

这样做的最佳方法是什么,因为我有大量的10k记录存储在HashSet中?

slo*_*oth 10

用途UnionWith:

修改当前HashSet对象以包含其自身,指定集合或两者中存在的所有元素.

hash.UnionWith(names);
Run Code Online (Sandbox Code Playgroud)