For List
s I could use the Union
method:
var finalCollection = new List<MyType>();
var list1= new List<MyType>();
var list2 = new List<MyType>();
finalCollection = list1.Union(list2).ToList();
But when I try to do the same with ConcurrentBag
s,
var finalCollection = new ConcurrentBag<MyType>();
var bag1= new ConcurrentBag<MyType>();
var bag2= new ConcurrentBag<MyType>();
finalCollection = bag1.Union(bag2);
I get:
Cannot implicitly convert type "System.Collections.Generic.IEnumerable< MyType>" to "System.Collections.Concurrent.ConcurrentBag"