int[] numbersA = { 0,2,4,5,6,8,9 }; int[] numbersB = { 1,3,7,8 }; var pairs = from a in numbersA from b in numbersB where a < b select new { a,b };
int[] numbersA = { 0,9 }; int[] numbersB = { 1,8 }; pairs = numbersA .SelectMany(_ => numbersB,(a,b) => new { a,b }) .Where(x => x.a < x.b);
原来的查询被翻译成:
int[] numbersA = { 0,b }) .Where(x => x.a < x.b) .Select(x => new { x.a,x.b });
但是最后一个选择不是必需的,可以被删除.