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 ...
随机推荐
- javaScript中eval()方法转换json对象
<script language="javascript"> var user = '{name:"张三",age:23,'+ 'address:{ ...
- VS Bug 当获取其他项目的代码时, F5 无法进入调试模式. 也不报错....
在64位的机子下, 被获用的项目使用X86时会出现. 就会出现 F5 无法进入调试模式. 也不报错.... 打断点也没有用. 在不加入X86项目的代码时, 又可以运行.. 解决方案: 检查 ...
- uitableviewcell 和 uibutton
如果cell上面只有一个button 可以设置button.tag=IndexPath.Row;得到当前点击的行数,设置button属性的时候,可以设置一个全局的button来记住当前点击的butt ...
- GIS数据格式topojson
Topojson源自于GeoJson,是D3中描述地理数据的格式,D3的作者觉得GeoJson太繁琐.同样的数据,TopoJson是GeoJson的1/5. 这里有一个转换TopoJson,GeoJs ...
- Sqli-labs less 20
Less-20 从源代码中我们可以看到cookie从username中获得值后,当再次刷新时,会从cookie中读取username,然后进行查询. 登录成功后,我们修改cookie,再次刷新时,这时 ...
- cf div2 238 c
C. Unusual Product time limit per test 1 second memory limit per test 256 megabytes input standard i ...
- CMD窗口正确显示UTF-8字符
Go语言教程 http://yiibai.com/go/ CMD窗口正确显示UTF-8字符 http://www.360doc.com/content/13/0424/13/2569758_280 ...
- POJ 1316
#include<iostream> using namespace std; #define NUM 10000 int main(){ }; int i; ; int j; ;i< ...
- Javascript format方法
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <m ...
- FZU Problem 2148 Moon Game (判断凸四边形)
题目链接 题意 : 给你n个点,判断能形成多少个凸四边形. 思路 :如果形成凹四边形的话,说明一个点在另外三个点连成的三角形内部,这样,只要判断这个内部的点与另外三个点中每两个点相连组成的三个三角形的 ...