Join 2 lists have different length by in LINQ
问题 How can I join 2 lists of different lengths. it should join with the sequence. Eg. {1,2,3,4} with {5,6,7} I need to get result like below. {{1,5}, {2,6}, {3,7}, {4,null}} I tried this. var qry = a.Select((i, index) => new {i, j = b[index]}); But its throwing error since the lists are having different lengths. Please help me to get the solution. 回答1: This should work: var a = new int?[] { 1, 2, 3, 4 }; var b = new int?[] { 5, 6, 7 }; var result = Enumerable.Range(0, Math.Max(a.Count(), b.Count