首页 > 编程语言 > 详细

Enumerable.SequenceEqual

时间:2016-02-16 14:57:26      阅读:201      评论:0      收藏:0      [点我收藏+]

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

原文:http://www.cnblogs.com/chucklu/p/5192477.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!