您可以使用 linq 到 GroupJoin:
string[] arr1 = { "1155717", "5184305", "2531291", "1676341", "1916805" };
string[] arr2 = { "1155717", "1440230", "2531291", "8178626", "1916805" };
string[] arr3 = { "1155717", "5184305", "4025514", "1676341" };
var allPossibleTerms = arr1.Union(arr2).Union(arr3);
allPossibleTerms
.GroupJoin(arr1, all => all, a1 => a1, (all, a1) => new { Number = all, A1 = a1 })
.SelectMany(joined => joined.A1.DefaultIfEmpty(), (collection, result) => new { collection.Number, A1 = result})
.GroupJoin(arr2, joined => joined.Number, a2 => a2, (collection, a2) => new { Number = collection.Number, A1 = collection.A1, A2 = a2 })
.SelectMany(joined => joined.A2.DefaultIfEmpty(), (collection, result) => new { collection.Number, A1 = collection.A1, A2 = result})
.GroupJoin(arr3, joined => joined.Number, a3 => a3, (collection, a3) => new { Number = collection.Number, A1 = collection.A1, A2 = collection.A2, A3 = a3 })
.SelectMany(joined => joined.A3.DefaultIfEmpty(), (collection, result) => new { collection.Number, A1 = collection.A1, A2 = collection.A2, A3 = result});;
基本上,这会创建所有术语的主列表,并随时加入每个数组。
╔══════════════════════════════════════╗
║ Number A1 A2 A3 ║
╠══════════════════════════════════════╣
║ 1155717 1155717 1155717 1155717 ║
║ 5184305 5184305 ------- 5184305 ║
║ 2531291 2531291 2531291 ------- ║
║ 1676341 1676341 ------- 1676341 ║
║ 1916805 1916805 1916805 ------- ║
║ 1440230 ------- 1440230 ------- ║
║ 8178626 ------- 8178626 ------- ║
║ 4025514 ------- ------- 4025514 ║
╚══════════════════════════════════════╝