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 ...
随机推荐
- php中==与===区别
==是不判断二者是否是同一数据类型,而===是更为严格的比较,它不但要求二者值相等,而且还要求它们的数据类型也相同
- 通过spring.net中的spring.caching CacheResult实现memcached缓存
通过spring.net中的spring.caching CacheResult实现memcached缓存1.SpringMemcachedCache.cs2.APP.config3.Program. ...
- VC5509的通用GEL代码
GEL是通用扩展语言(General Extension Language)的英文缩写,GEL是一个大小写敏感但缺少类型检测的解释性语言,只有int类型,在语法上可看作是C语言的一个子集.GEL主要用 ...
- JS This关键字
http://www.ruanyifeng.com/blog/2010/04/using_this_keyword_in_javascript.html http://www.cnblogs.com/ ...
- 一个有趣的Ajax Hack示范
今天在梦之光芒的BLOG上看见了一个Ajax Hack示范,其实跨站发现很容易,但是要做到大危害还是很难,偷偷COOKIE什么的只针对用户而已,XSS WORM的那种利用才是可怕的. 来看看他的一段V ...
- flashdevelop 开发技巧
FlashDevelop用来编写AS3代码,Flash CS5用来编辑程序所需要的资源(图片,声音-),Flash CS5自带有Flex SDK,在目录 C:\Program Files\Adobe\ ...
- delphi中locate方法
TDataSet控件以及它的继承控件,例如TSimpleDataSet/TClientDataSet等都可以使用Locate方法在结果数据集中查寻数据.程序首先必须使用SQL命令从后端数据库中取得数据 ...
- MySQL 数据库存储引擎
简单介绍 存储引擎就是指表的类型.数据库的存储引擎决定了表在计算机中的存储方式.存储引擎的概念是MySQl的特点,而且是一个插入式的存储引擎概念.这就决定了MySQl数据库中的表可以使用不同的存储方式 ...
- Tomcat目录结构
首先来了解一下Tomcat5.5的目录结构: /bin:存放windows或Linux平台上启动和关闭Tomcat的脚本文件 /conf:存放Tomcat服务器的各种全局配置文件,其中包括server ...
- shell脚本替换文件中字符
1.将当前目录下包含jack串的文件中,jack字符串替换为tom sed -i "s/jack/tom/g" `grep "jack" -rl ./` 2.将 ...