MemoryExtensions.SequenceEqual Method

Definition

Overloads

SequenceEqual<T>(ReadOnlySpan<T>, ReadOnlySpan<T>)

Determines whether two read-only sequences are equal by comparing the elements using IEquatable{T}.Equals(T).

SequenceEqual<T>(Span<T>, ReadOnlySpan<T>)

Determines whether a span and a read-only span are equal by comparing the elements using IEquatable{T}.Equals(T).

SequenceEqual<T>(ReadOnlySpan<T>, ReadOnlySpan<T>, IEqualityComparer<T>)

Determines whether two sequences are equal by comparing the elements using an IEqualityComparer<T>.

SequenceEqual<T>(Span<T>, ReadOnlySpan<T>, IEqualityComparer<T>)

Determines whether two sequences are equal by comparing the elements using an IEqualityComparer<T>.

SequenceEqual<T>(ReadOnlySpan<T>, ReadOnlySpan<T>)

Source:
MemoryExtensions.cs
Source:
MemoryExtensions.cs
Source:
MemoryExtensions.cs

Determines whether two read-only sequences are equal by comparing the elements using IEquatable{T}.Equals(T).

public static bool SequenceEqual<T> (this ReadOnlySpan<T> span, ReadOnlySpan<T> other) where T : IEquatable<T>;

Type Parameters

T

The type of elements in the sequence.

Parameters

span
ReadOnlySpan<T>

The first sequence to compare.

other
ReadOnlySpan<T>

The second sequence to compare.

Returns

true if the two sequences are equal; otherwise, false.

Applies to

.NET 9 and other versions
Product Versions
.NET Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 4.7 (package-provided), 4.7.1 (package-provided), 4.7.2 (package-provided), 4.8 (package-provided)
.NET Standard 2.0 (package-provided), 2.1

SequenceEqual<T>(Span<T>, ReadOnlySpan<T>)

Source:
MemoryExtensions.cs
Source:
MemoryExtensions.cs
Source:
MemoryExtensions.cs

Determines whether a span and a read-only span are equal by comparing the elements using IEquatable{T}.Equals(T).

public static bool SequenceEqual<T> (this Span<T> span, ReadOnlySpan<T> other) where T : IEquatable<T>;

Type Parameters

T

The type of elements in the sequence.

Parameters

span
Span<T>

The span to compare.

other
ReadOnlySpan<T>

The read-only span to compare.

Returns

true if the two sequences are equal; otherwise, false.

Applies to

.NET 9 and other versions
Product Versions
.NET Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 4.7 (package-provided), 4.7.1 (package-provided), 4.7.2 (package-provided), 4.8 (package-provided)
.NET Standard 2.0 (package-provided), 2.1

SequenceEqual<T>(ReadOnlySpan<T>, ReadOnlySpan<T>, IEqualityComparer<T>)

Source:
MemoryExtensions.cs
Source:
MemoryExtensions.cs
Source:
MemoryExtensions.cs

Determines whether two sequences are equal by comparing the elements using an IEqualityComparer<T>.

public static bool SequenceEqual<T> (this ReadOnlySpan<T> span, ReadOnlySpan<T> other, System.Collections.Generic.IEqualityComparer<T>? comparer = default);

Type Parameters

T

The type of elements in the sequence.

Parameters

span
ReadOnlySpan<T>

The first sequence to compare.

other
ReadOnlySpan<T>

The second sequence to compare.

comparer
IEqualityComparer<T>

The IEqualityComparer<T> implementation to use when comparing elements, or null to use the default IEqualityComparer<T> for the type of an element.

Returns

true if the two sequences are equal; otherwise, false.

Applies to

.NET 9 and other versions
Product Versions
.NET 6, 7, 8, 9

SequenceEqual<T>(Span<T>, ReadOnlySpan<T>, IEqualityComparer<T>)

Source:
MemoryExtensions.cs
Source:
MemoryExtensions.cs
Source:
MemoryExtensions.cs

Determines whether two sequences are equal by comparing the elements using an IEqualityComparer<T>.

public static bool SequenceEqual<T> (this Span<T> span, ReadOnlySpan<T> other, System.Collections.Generic.IEqualityComparer<T>? comparer = default);

Type Parameters

T

The type of elements in the sequence.

Parameters

span
Span<T>

The first sequence to compare.

other
ReadOnlySpan<T>

The second sequence to compare.

comparer
IEqualityComparer<T>

The IEqualityComparer<T> implementation to use when comparing elements, or null to use the default IEqualityComparer<T> for the type of an element.

Returns

true if the two sequences are equal; otherwise, false.

Applies to

.NET 9 and other versions
Product Versions
.NET 6, 7, 8, 9