Language

MemoryExtensions.Contains Method

Definition

Indicates whether a specified value is found in a span.

Overloads

Name Description
Contains(ReadOnlySpan, ReadOnlySpan, StringComparison)

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

Contains(ReadOnlySpan, T)

Indicates whether a specified value is found in a read-only span.

Contains(Span, T)

Indicates whether a specified value is found in a span.

Contains(ReadOnlySpan, T, IEqualityComparer)

Searches for the specified value and returns true if found. If not found, returns false.

Contains(ReadOnlySpan, ReadOnlySpan, StringComparison)

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

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

public:
[System::Runtime::CompilerServices::Extension]
 static bool Contains(ReadOnlySpan span, ReadOnlySpan value, StringComparison comparisonType);
public static bool Contains(this ReadOnlySpan span, ReadOnlySpan value, StringComparison comparisonType);
static member Contains : ReadOnlySpan * ReadOnlySpan * StringComparison -> bool

Public Function Contains (span As ReadOnlySpan(Of Char), value As ReadOnlySpan(Of Char), comparisonType As StringComparison) As Boolean

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

Contains(ReadOnlySpan, T)

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

Indicates whether a specified value is found in a read-only span.

public:
generic 
 where T : IEquatable[System::Runtime::CompilerServices::Extension]
 static bool Contains(ReadOnlySpan span, T value);
public static bool Contains(this ReadOnlySpan span, T value) where T : IEquatable;
static member Contains : ReadOnlySpan<'T (requires 'T :> IEquatable<'T>)> * 'T -> bool (requires 'T :> IEquatable<'T>)

Public Function Contains(Of T As IEquatable(Of T)) (span As ReadOnlySpan(Of T), value As T) As Boolean

Type Parameters

T

The type of the span.

Parameters

span
ReadOnlySpan

The span to search.

value
T

The value to search for.

Returns

true if found, false otherwise.

Remarks

Values are compared using IEquatable{T}.Equals(T).

Applies to

Contains(Span, T)

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

Indicates whether a specified value is found in a span.

public:
generic 
 where T : IEquatable[System::Runtime::CompilerServices::Extension]
 static bool Contains(Span span, T value);
[System.Runtime.CompilerServices.OverloadResolutionPriority(-1)]
public static bool Contains(this Span span, T value) where T : IEquatable;
public static bool Contains(this Span span, T value) where T : IEquatable;
[]
static member Contains : Span<'T (requires 'T :> IEquatable<'T>)> * 'T -> bool (requires 'T :> IEquatable<'T>)
static member Contains : Span<'T (requires 'T :> IEquatable<'T>)> * 'T -> bool (requires 'T :> IEquatable<'T>)

Public Function Contains(Of T As IEquatable(Of T)) (span As Span(Of T), value As T) As Boolean

Type Parameters

T

The type of the elements in the span.

Parameters

span
Span

The span to search.

value
T

The value to search for.

Returns

true if found, false otherwise.

Attributes

Remarks

Values are compared using IEquatable{T}.Equals(T).

Applies to

Contains(ReadOnlySpan, T, IEqualityComparer)

Source:
MemoryExtensions.cs
Source:
MemoryExtensions.cs

Searches for the specified value and returns true if found. If not found, returns false.

public static bool Contains(this ReadOnlySpan span, T value, System.Collections.Generic.IEqualityComparer? comparer = default);
static member Contains : ReadOnlySpan<'T> * 'T * System.Collections.Generic.IEqualityComparer<'T> -> bool

Public Function Contains(Of T) (span As ReadOnlySpan(Of T), value As T, Optional comparer As IEqualityComparer(Of T) = Nothing) As Boolean

Type Parameters

T

Parameters

span
ReadOnlySpan

The span to search.

value
T

The value to search for.

comparer
IEqualityComparer

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

Returns

Applies to