SequenceEqual(TSource) Method (IEnumerable(TSource), IEnumerable(TSource), IEqualityComparer(TSource))

Enumerable.SequenceEqual(Of TSource) Method (IEnumerable(Of TSource), IEnumerable(Of TSource), IEqualityComparer(Of TSource))

[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]

Determines whether two sequences are equal by comparing their elements by using a specified IEqualityComparer(Of T).

Namespace:  System.Linq
Assembly:  System.Core (in System.Core.dll)

'Declaration
<ExtensionAttribute> _
Public Shared Function SequenceEqual(Of TSource) ( _
	first As IEnumerable(Of TSource), _
	second As IEnumerable(Of TSource), _
	comparer As IEqualityComparer(Of TSource) _
) As Boolean

Type Parameters

TSource

The type of the elements of the input sequences.

Parameters

first
Type: System.Collections.Generic.IEnumerable(Of TSource)
An IEnumerable(Of T) to compare to second.
second
Type: System.Collections.Generic.IEnumerable(Of TSource)
An IEnumerable(Of T) to compare to the first sequence.
comparer
Type: System.Collections.Generic.IEqualityComparer(Of TSource)
An IEqualityComparer(Of T) to use to compare elements.

Return Value

Type: System.Boolean
true if the two source sequences are of equal length and their corresponding elements compare equal according to comparer; otherwise, false.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type IEnumerable(Of TSource). When you use instance method syntax to call this method, omit the first parameter.

ExceptionCondition
ArgumentNullException

first or second is Nothing.

InvalidOperationException

source has more than one element.

The SequenceEqual(Of TSource)(IEnumerable(Of TSource), IEnumerable(Of TSource), IEqualityComparer(Of TSource)) method enumerates the two source sequences in parallel and compares corresponding elements by using the specified IEqualityComparer(Of T). If comparer is Nothing, the default equality comparer, Default, is used to compare elements.

Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Windows Phone

Show:
© 2017 Microsoft