I have 3 List<> objects.
List<T> listA = new List<t>();
List<T> listB = new List<t>();
List<T> listC = new List<t>();
I need to unite listA and ListB and assign it to ListC:
List<T> listC = new ListA +ListB;
My question is how to implement it?
List<int> A = new List<int>();
A.Add(1);
A.Add(2);
List<int> B = new List<int>();
B.Add(3);
B.Add(4);
List<int> C = new List<int>();
C = A.Union<int>(B).ToList<int>();
Use AddRange:
List<T> listA = new List<t>();
List<T> listB = new List<t>();
List<T> listC = new List<t>();
listC.AddRange(listA);
listC.AddRange(listB);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With