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. Poj 1032 分类: Translation Mode 2014-04-04 09:09 111人阅读 评论(0) 收藏

    Parliament Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 16521   Accepted: 6975 Descr ...

  2. frequentism-and-bayesianism-chs

    frequentism-and-bayesianism-chs 频率主义和贝叶斯主义——一个实用的介绍 此notebook最初出现在博客Pythonic Perambulations的文章.BSD l ...

  3. [Bug]The maximum array length quota (16384) has been exceeded while reading XML data.

    写在前面 在项目中,有客户反应无法正常加载组织结构树,弄了一个测试的程序,在日志中查看到如下信息: Error in deserializing body of reply message for o ...

  4. 你用什么工具开发JavaScript?

    Cloud9的CFO曾经在LinkedIn上面发起一个调查,原标题为:What tools do you use for Node.js development?,回贴者甚多. 目测很多人都使用VIM ...

  5. [初级教程]用SecureCRT+Xming轻松远程实现Linux的X DISPLAY

    [初级教程]用SecureCRT+Xming轻松远程实现Linux的X DISPLAY 发布者:sqqdugdu 时间:10-06 阅读数:2117 测试环境:RHEL 6.1,SecureCRT 5 ...

  6. UITextField输入中文限制

      [self.textField addTarget:self action:@selector(textFieldDidChange:) forControlEvents:UIControlEve ...

  7. Linux下安装Scim-googlepinyin输入法和设置Sublime Text中文输入

    1.安装git sudo apt-get install git http://www.cnblogs.com/perseus/archive/2012/01/06/2314069.html 2.获取 ...

  8. lintcode:买卖股票的最佳时机 III

    买卖股票的最佳时机 III 假设你有一个数组,它的第i个元素是一支给定的股票在第i天的价格.设计一个算法来找到最大的利润.你最多可以完成两笔交易. 样例 给出一个样例数组 [4,4,6,1,1,4,2 ...

  9. 【转】terminal 快捷键

    转自:http://www.jb51.net/os/Ubuntu/141723.html 1.gnome-terminal快捷键设置方法: 系统 —> 首选项 ->键盘快捷键 -> ...

  10. weblogic 安装与配置

    Weblogic 安装 从官网 下载 需要的weblogic 版本, 解压缩后得到 wls1036_generic.jar [fmw_12.1.3.0.0_wls.jar , fmw_12.2.1.1 ...