How do you concatenate Lists in C#?

前端 未结 6 1970
闹比i
闹比i 2020-12-23 13:09

If I have:

List myList1;
List myList2;

myList1 = getMeAList();
// Checked myList1, it contains 4 strings

myList2 = getMeAnother         


        
6条回答
  •  感动是毒
    2020-12-23 13:22

    targetList = list1.Concat(list2).ToList();
    

    It's working fine I think so. As previously said, Concat returns a new sequence and while converting the result to List, it does the job perfectly.

提交回复
热议问题