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的更多相关文章

  1. LINQ Enumerable 续

    筛选序列 Enumerable.Distinct 对于复杂的对象列表,运行时引擎如何才能通过比较确定两个对象是否重复?对于复杂对象,必须提供一个比较器,即实现IEqualityComparer(Of ...

  2. .NET LINQ 相等运算

    相等运算      如果两个序列的对应元素相等且这两个序列具有相同数量的元素,则视这两个序列相等. 方法 方法名 说明 C# 查询表达式语法 Visual Basic 查询表达式语法 更多信息 Seq ...

  3. 一种集合“相等性”的实现

        最近在工作中遇到了一个小的功能,就是需要向一个服务发送请求命令,需要判断请求是否发生变化,如果发生变化了,则重新请求.该问题实际上就是判断两个集合是否相等,只需要记录最后一次请求的元素的集合, ...

  4. (C#基础) byte[] 之初始化, 赋值,转换。(转)

    byte[] 之初始化赋值 用for loop 赋值当然是最基本的方法,不过在C#里面还有其他的便捷方法. 1. 创建一个长度为10的byte数组,并且其中每个byte的值为0. byte[] myB ...

  5. Linq中疏漏的几个知识点

    1.Union - 连接不同集合,自动过滤相同项 2.Concat - 连接不同集合,不会自动过滤相同项 3.Select - 类似List的ConvertAll,转换集合成员 4.Enumerabl ...

  6. NopCommerce开源项目中很基础但是很实用的C# Helper方法

    刚过了个五一,在杭州到处看房子,不知道杭州最近怎么了,杭州买房的人这么多,房价涨得太厉害,这几年翻倍翻倍地涨,刚过G20,又要亚运会,让我这样的刚需用户买不起,也买不到房子,搞得人心惶惶,太恐怖了,心 ...

  7. 判断PDF文件是否相同(通过二进制流判断)

    一.Java代码 1.将PDF转为字节流    /*     * @step     *  1.使用BufferedInputStream和FileInputStream从File指定的文件中读取内容 ...

  8. ReactiveX 学习笔记(12)调度器

    Schedulers, threading and testing 本文的主题为调度器,多线程以及测试. RxJava操作符(六)Utility SubscribeOn / ObserveOn Sub ...

  9. 工作总结 string数组 排序 string数组 比较

    用到   工具类 Array 创建.处理.搜索数组并对数组进行排序 Enumerable  提供一组用于查询实现 System.Collections.Generic.IEnumerable<T ...

随机推荐

  1. 【BZOJ】【1041】【HAOI2008】圆周上的点

    数学 orz hzwer 完全不会做…… 很纠结啊,如果将来再遇到这种题,还是很难下手啊…… 引用题解: [分析]: 样例图示: 首先,最暴力的算法显而易见:枚举x轴上的每个点,带入圆的方程,检查是否 ...

  2. Leetcode#89 Gray Code

    原题地址 二进制码 -> 格雷码:从最右边起,依次与左边相邻位异或,最左边一位不变.例如: 二进制: 1 0 0 1 1 1 0 |\|\|\|\|\|\| 格雷码: 1 1 0 1 0 0 1 ...

  3. MySQL 5.7 reference about JSON

    最近需要用到MySQL 5.7中的JSON,总结一下MySQL中关于JSON的内容 参考: 11.6 The JSON Data Type 12.16 JSON Functions JSON Func ...

  4. Unity3D 将 Unity 嵌入WPF中的一些研究笔记

     一. 在 WPF 中使用 WebBrowser,直接打开 WebPlayer.html 以这种方式有一个问题是. 无法在 WebBrowser 的上面 放置其它的控件, 在运行时,都不会显示 . 以 ...

  5. Ambient Occlusion

    一般在光照模型中,ambient light的计算方法为:A = l * m,其中l表示表面接收到的来自光源的ambient light的总量,而m表示表面接收到ambient light后,反射和吸 ...

  6. 有关npm rum的3个简洁技巧

    [编者按]本文作者为来自 MongoDB 的 NodeJS 工程师 Valeri Karpov.Valeri 专注于维护常见的 Mongoose ODM,是<Professional Angul ...

  7. ZOJ 2971 Give Me the Number;ZOJ 2311 Inglish-Number Translator (字符处理,防空行,strstr)

    ZOJ 2971 Give Me the Number 题目 ZOJ 2311 Inglish-Number Translator 题目 //两者题目差不多,细节有点点不一样,因为不是一起做的,所以处 ...

  8. ThinkPHP 单字母函数整理

    TP所有单独的函数,除了两个用来生成项目的buildAppDir之类的,其余都在框架目录/Common/functions.php这个文件里. A函数(基本是Action的简写) A函数是用来实例化我 ...

  9. Linux多线程之同步

    引言 条件变量是利用线程间共享的全局变量进行同步的一种机制,主要包括两个动作:一个线程等待条件变量的条件成立而挂起(此时不再占用cpu):另一个线程使条件成立(给出条件成立信号).为了防止竞争,条件变 ...

  10. 李洪强iOS开发之OC[011] - 有参方法的声明实现以及调用练习