I have two lists, both from different lengths. What I'm trying to achieve is a third list containing the first item from list1, then the first item from list2, then the second item from list1 and the second item from list2, etc. Until one of the two is exhausted (they are "uneven"), and then just add all the remaining items from this list.
the result should have the same number of elements as list1 and list2.
I cannot use something like Union.ToList (), since this does not interweave the two, it just adds all the elements from the list1 example to the end of list2 and displays it as a result. I tried .Zip (Linq), however, it looks like they take in two elements and combine them into one element (namely, concatenating two strings into one long string).
List<string> list1 = new List<string>(){
"4041",
"4040"
};
List<string> list2 = new List<string>(){
"4039",
"4044",
"4075",
"4010",
"4100",
"4070",
"4072"
};
result = { "4041",
"4039",
"4040"
"4044",
"4075",
"4010",
"4100",
"4070",
"4072"
};
source
share