标签:
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace 用Join子句进行分组联接 { class Program { static void Main(string[] args) { int[] intAry1 = { 5, 15, 25, 30, 33, 40 }; int[] intAry2 = { 10, 20, 30, 50, 60, 70, 80 }; var query1 = from val1 in intAry1 //在数组intAry1中取到val1 join val2 in intAry2 //同时在数组intAry2中取到val2 on val1%5 equals val2%15 into val2Grp //val2Grp中的数据是val1和val2的两个对象,而不是记录 where val2Grp.Count()!=0 //new { VAL1 = val1, VAL2GRP = val2Grp产生一个新类型 select (new { VAL1 = val1, VAL2GRP = val2Grp }); //遍历新的数据类型 foreach(var item in query1) { foreach(int item1 in item.VAL2GRP) { Console.WriteLine(item.VAL1+" "+item1.ToString()); } } System.Console.ReadKey(); } } }
标签:
原文地址:http://www.cnblogs.com/cnshuji/p/5450150.html