Enumerable.SequenceEqual
Determines whether two sequences are equal by comparing the elements by using the default equality comparer for their type.
public static bool SequenceEqual<TSource>(
this IEnumerable<TSource> first,
IEnumerable<TSource> second
)
Type Parameters
- TSource
-
The type of the elements of the input sequences.
Parameters
- first
- Type: System.Collections.Generic.IEnumerable<TSource>
An IEnumerable<T> to compare to second.
- second
- Type: System.Collections.Generic.IEnumerable<TSource>
Return Value
Type: System.Boolean
true if the two source sequences are of equal length and their corresponding elements are equal according to the default equality comparer for their type; otherwise, false.
Usage Note
In Visual Basic and C#, you can call this method as an instance method on any object of type IEnumerable<TSource>.
When you use instance method syntax to call this method, omit the first parameter.
For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).
Remarks
The SequenceEqual<TSource>(IEnumerable<TSource>, IEnumerable<TSource>) method enumerates the two source sequences in parallel and compares corresponding elements by using the default equality comparer for TSource, Default.
The default equality comparer, Default, is used to compare values of the types that implement the IEqualityComparer<T> generic interface.
To compare a custom data type, you need to implement this interface and provide your own GetHashCode and Equals methods for the type.
具体的引用,可以参看这个http://www.codewars.com/kata/are-the-numbers-in-order/solutions/csharp
Enumerable.SequenceEqual的更多相关文章
- LINQ Enumerable 续
筛选序列 Enumerable.Distinct 对于复杂的对象列表,运行时引擎如何才能通过比较确定两个对象是否重复?对于复杂对象,必须提供一个比较器,即实现IEqualityComparer(Of ...
- .NET LINQ 相等运算
相等运算 如果两个序列的对应元素相等且这两个序列具有相同数量的元素,则视这两个序列相等. 方法 方法名 说明 C# 查询表达式语法 Visual Basic 查询表达式语法 更多信息 Seq ...
- 一种集合“相等性”的实现
最近在工作中遇到了一个小的功能,就是需要向一个服务发送请求命令,需要判断请求是否发生变化,如果发生变化了,则重新请求.该问题实际上就是判断两个集合是否相等,只需要记录最后一次请求的元素的集合, ...
- (C#基础) byte[] 之初始化, 赋值,转换。(转)
byte[] 之初始化赋值 用for loop 赋值当然是最基本的方法,不过在C#里面还有其他的便捷方法. 1. 创建一个长度为10的byte数组,并且其中每个byte的值为0. byte[] myB ...
- Linq中疏漏的几个知识点
1.Union - 连接不同集合,自动过滤相同项 2.Concat - 连接不同集合,不会自动过滤相同项 3.Select - 类似List的ConvertAll,转换集合成员 4.Enumerabl ...
- NopCommerce开源项目中很基础但是很实用的C# Helper方法
刚过了个五一,在杭州到处看房子,不知道杭州最近怎么了,杭州买房的人这么多,房价涨得太厉害,这几年翻倍翻倍地涨,刚过G20,又要亚运会,让我这样的刚需用户买不起,也买不到房子,搞得人心惶惶,太恐怖了,心 ...
- 判断PDF文件是否相同(通过二进制流判断)
一.Java代码 1.将PDF转为字节流 /* * @step * 1.使用BufferedInputStream和FileInputStream从File指定的文件中读取内容 ...
- ReactiveX 学习笔记(12)调度器
Schedulers, threading and testing 本文的主题为调度器,多线程以及测试. RxJava操作符(六)Utility SubscribeOn / ObserveOn Sub ...
- 工作总结 string数组 排序 string数组 比较
用到 工具类 Array 创建.处理.搜索数组并对数组进行排序 Enumerable 提供一组用于查询实现 System.Collections.Generic.IEnumerable<T ...
随机推荐
- 【BZOJ】【1912】【APIO2010】patrol巡逻
树形DP 说是树形DP,其实就是求树的最长链嘛…… K=1的时候明显是将树的最长链的两端连起来最优. 但是K=2的时候怎么搞? 考虑第一次找完树的最长链以后的影响:第一次找过的边如果第二次再走,对答案 ...
- 【BZOJ】【1552】【Cerc2007】robotic sort / 【3506】【CQOI2014】排序机械臂
Splay 离散化+Splay维护序列…… 好吧主要说一下我做这道题遇到的几个错误点: 1.离散化 2.由于找到的这个数的位置一定是大于等于 i 的,所以其实在把它splay到根以后,i 结点只能sp ...
- Java/Java Web中乱码解决汇总
在开发Java/Java Web Application过程中,往往会出现乱码问题,而且有的时候真会弄得人很烦,浪费太多的时间. 记得之前看过一篇帖子,详细解释了Encoding/Decoding过程 ...
- Task相关
1.Task的优势: 1)把任务当成变量来用,可以作为参数而传递: 2)可以捕获到异步操作中发生的异常. 2.开始异步 Task.Factory.StartNew(() => Thread.Sl ...
- Leetcode#99 Recover Binary Search Tree
原题地址 中序遍历二叉搜索树,正常情况下所有元素都应该按递增排列,如果有元素被交换,则会出现前面元素大于后面的情况,称作反序.由于交换了两个节点,所以通常会有两处反序,但如果是两个相邻节点发生了交换, ...
- 浅谈ASP.NET报表控件
OWC似乎使用者居多,但看见有网友在帖中抱怨OWC在使用时需要许可证书,于是将其排除,我可不想BOSS在看报表时弹出一个“没有许可证书”的窗口. 接着找到了ComponentOne的Web chart ...
- javascript设计模式--状态模式(State)
<!doctype html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- UVA 11795
B Mega Man’s Missions Input Standard Input Output Standard Output Mega Man is off to save the world ...
- Android线程消息通信(二)
创建线程消息队列 Android应用程序的消息队列是使用一个MessageQueue对象来描述的,它可以通过调用Looper类的静态成员函数prepareMainLooper或者prepare来创建, ...
- ESASP 业界第一个最为完善的 ASP MVC框架(待续)
EchoSong 疯狂了,竟然整ASP框架. ASP就是抛弃的孩子,没人养没人疼的, 智力.四肢不全.何谈框架?? 很多ASP的前辈们要么放弃ASP 投入 ASP.net 或者 PHP怀抱.要么直接用 ...