对于List
s 我可以使用以下Union
方法:
var finalCollection = new List<MyType>();
var list1= new List<MyType>();
var list2 = new List<MyType>();
finalCollection = list1.Union(list2).ToList();
但是当我尝试对ConcurrentBag
s 做同样的事情时,
var finalCollection = new ConcurrentBag<MyType>();
var bag1= new ConcurrentBag<MyType>();
var bag2= new ConcurrentBag<MyType>();
finalCollection = bag1.Union(bag2);
我得到:
无法将类型“System.Collections.Generic.IEnumerable<MyType>”隐式转换为“System.Collections.Concurrent.ConcurrentBag”