我怎么走直角连接两个列表在C#? [英] How do I take the Cartesian join of two lists in c#?
本文介绍了我怎么走直角连接两个列表在C#?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我如何把笛卡尔在其中?
How do I take the Cartesian join of two lists with integers in them?
可以这样使用LINQ做什么?
Can this be done with linq?
推荐答案
假设你的意思是交叉连接或笛卡尔加盟:
Assuming you mean a "cross join" or "Cartesian join":
var query = from x in firstList
from y in secondList
select new { x, y }
或者
var query = firstList.SelectMany(x => secondList, (x, y) => new { x, y });
如果你想要别的东西(你可以从注释中看到,所谓跨产品已造成有些混乱),请做适当修改你的问题。一个例子是非常方便的:)
If you want something else (as you can see from comments, the term "cross product" has caused some confusion), please edit your question appropriately. An example would be very handy :)
这篇关于我怎么走直角连接两个列表在C#?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文