i have 2 lists:
List 1 = {"1", "2", "", "", "4", ""}
List 2 = {"3", "4", "5", "", "6", ""}
I want a new List:
List 3 = {"1, 3", "2, 4", "5", "", "4, 6", ""};
How can i get this result?
i have 2 lists:
List 1 = {"1", "2", "", "", "4", ""}
List 2 = {"3", "4", "5", "", "6", ""}
I want a new List:
List 3 = {"1, 3", "2, 4", "5", "", "4, 6", ""};
How can i get this result?
You can use Enumerable.Zip
with string.Join
for this:
var result = list1
.Zip(list2, (a, b) => string.Join(", ", new[] { a, b }.Where(x => x != "")))
.ToList();