假设我有两个集合
int[] foo = { 1, 2, 3, 4 };
int[] bar = { 2, 4, 6, 8 };
使用 linq 选择存在于两个集合中的值的最简单方法是什么?
即包含 2 和 4 的集合。
最佳答案
int[] result = foo.Intersect(bar).ToArray();
关于c# - 使用 LINQ 查找存在于两个集合中的元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6608916/