除了具有鲜明的类似的效果? [英] Except has similar effect to Distinct?

查看:83
本文介绍了除了具有鲜明的类似的效果?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚发现,除()将删除从第一第二列表中的所有元素,但它也有它使得在返回结果中的所有元素的影响。各地不同的

I just discovered that Except() will remove all elements in the second list from the first, but it also has the effect that it makes all elements in the returned result distinct.

简单的方法我现在用的就是其中(v =>!secondList.Contains(v))

Simple way around I am using is Where(v => !secondList.Contains(v))

谁能给我解释一下为什么是这样的行为,如果可能的话一点我解释这个文件?

Can anyone explain to me why this is the behavior, and if possible point me to the documentation that explains this?

推荐答案

除了 功能状态:

The documentation for the Except function states:

通过使用默认的相等比较器生成两个序列的差集对值进行比较

Produces the set difference of two sequences by using the default equality comparer to compare values.

的两个集合的集合差被定义为不显示在第二组中的第一组的成员。

The set difference of two sets is defined as the members of the first set that do not appear in the second set.

这里最重要的词是设置,这是的定义为

The important word here is set, which is defined as:

...一个抽象的数据可以存储一定的值,没有任何结构特定的顺序,也没有重复的值...

...an abstract data structure that can store certain values, without any particular order, and no repeated values...

由于除了被记录作为基于集合的操作,它也有使所得到的值不同的效果。

Because Except is documented as a set-based operation, it also has the effect of making the resulting values distinct.

这篇关于除了具有鲜明的类似的效果?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆