MemoryExtensions.StartsWith Method

Definition

Overloads

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

Determines whether a read-only character span begins with a specified value when compared using a specified StringComparison value.

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

Determines whether a specified sequence appears at the start of a span.

StartsWith<T>(ReadOnlySpan<T>, ReadOnlySpan<T>)

Determines whether a specified sequence appears at the start of a read-only span.

StartsWith<T>(ReadOnlySpan<T>, T)

Determines whether the specified value appears at the start of the span.

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

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

Determines whether a read-only character span begins with a specified value when compared using a specified StringComparison value.

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

Parameters

span
ReadOnlySpan<Char>

The source span.

value
ReadOnlySpan<Char>

The sequence to compare to the beginning of the source span.

comparisonType
StringComparison

An enumeration value that determines how span and value are compared.

Returns

true if value matches the beginning of span; 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

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

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

Determines whether a specified sequence appears at the start of a span.

C#
public static bool StartsWith<T>(this Span<T> span, ReadOnlySpan<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
ReadOnlySpan<T>

A sequence to search for at the start of span.

Returns

true if value matches the beginning of span; 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

StartsWith<T>(ReadOnlySpan<T>, ReadOnlySpan<T>)

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

Determines whether a specified sequence appears at the start of a read-only span.

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

Type Parameters

T

The type of elements in the span.

Parameters

span
ReadOnlySpan<T>

The read-only character span to search.

value
ReadOnlySpan<T>

A sequence to search for at the start of span.

Returns

true if value matches the beginning of span; 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

StartsWith<T>(ReadOnlySpan<T>, T)

Determines whether the specified value appears at the start of the span.

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

Type Parameters

T

The type of elements in the span.

Parameters

span
ReadOnlySpan<T>

The span to search.

value
T

The value to compare.

Returns

true if value matches the beginning of span; otherwise, false.

Applies to

.NET 9
Product Versions
.NET 9