MemoryExtensions.Contains Method

Definition

Overloads

Contains(ReadOnlySpan<Char>, ReadOnlySpan<Char>, StringComparison)

Indicates whether a specified value occurs within a read-only character span.

Contains<T>(ReadOnlySpan<T>, T)

Indicates whether a specified value is found in a read-only span. Values are compared using IEquatable{T}.Equals(T).

Contains<T>(Span<T>, T)

Indicates whether a specified value is found in a span. Values are compared using IEquatable{T}.Equals(T).

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

Contains(ReadOnlySpan<Char>, ReadOnlySpan<Char>, StringComparison)

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

Indicates whether a specified value occurs within a read-only character span.

C#
public static bool Contains(this ReadOnlySpan<char> span, ReadOnlySpan<char> value, StringComparison comparisonType);

Parameters

span
ReadOnlySpan<Char>

The source span.

value
ReadOnlySpan<Char>

The value to seek within the source span.

comparisonType
StringComparison

An enumeration value that determines how the characters in span and value are compared.

Returns

true if value occurs within the span, false otherwise.

Applies to

.NET 10 i druge verzije
Proizvod Verzije
.NET Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Standard 2.0 (package-provided), 2.1

Contains<T>(ReadOnlySpan<T>, T)

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

Indicates whether a specified value is found in a read-only span. Values are compared using IEquatable{T}.Equals(T).

C#
public static bool Contains<T>(this ReadOnlySpan<T> span, T value) where T : IEquatable<T>;

Type Parameters

T

The type of the span.

Parameters

span
ReadOnlySpan<T>

The span to search.

value
T

The value to search for.

Returns

true if found, false otherwise.

Applies to

.NET 10 i druge verzije
Proizvod Verzije
.NET Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10

Contains<T>(Span<T>, T)

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

Indicates whether a specified value is found in a span. Values are compared using IEquatable{T}.Equals(T).

C#
[System.Runtime.CompilerServices.OverloadResolutionPriority(-1)]
public static bool Contains<T>(this Span<T> span, T value) where T : IEquatable<T>;
C#
public static bool Contains<T>(this Span<T> span, T value) where T : IEquatable<T>;

Type Parameters

T

The type of the elements in the span.

Parameters

span
Span<T>

The span to search.

value
T

The value to search for.

Returns

true if found, false otherwise.

Attributes

Applies to

.NET 10 i druge verzije
Proizvod Verzije
.NET Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10

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

C#
public static bool Contains<T>(this ReadOnlySpan<T> span, T value, System.Collections.Generic.IEqualityComparer<T>? comparer = default);

Type Parameters

T

Parameters

value
T

Returns

Applies to

.NET 10
Proizvod Verzije
.NET 10