int[] arr1 = { 32, 3, 432, 543, 23, 5, 634 };
int[] arr2 = { 64, 4, 8, 3, 3, 6, 23, 5, 2 };
var query = from val in arr1 join val2 in arr2 on val equals val2 into temp
from grp in temp.DefaultIfEmpty()
select new { val, grp };
//DefaultIfEmpty(),匹配不上,会给个默认值,这里给0
foreach (var item in query)
{
Console.WriteLine(item);
}
Linq之左联接
最新推荐文章于 2024-07-24 09:13:49 发布