Ler en inglés Editar

Compartir por


MemoryExtensions.LastIndexOf Method

Definition

Important

Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.

Overloads

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

Reports the zero-based index of the last occurrence of the specified value in the current span.

LastIndexOf<T>(ReadOnlySpan<T>, ReadOnlySpan<T>)

Searches for the specified sequence and returns the index of its last occurrence. Values are compared using IEquatable{T}.Equals(T).

LastIndexOf<T>(ReadOnlySpan<T>, T)

Searches for the specified value and returns the index of its last occurrence. Values are compared using IEquatable{T}.Equals(T).

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

Searches for the specified sequence and returns the index of its last occurrence. Values are compared using IEquatable{T}.Equals(T).

LastIndexOf<T>(Span<T>, T)

Searches for the specified value and returns the index of its last occurrence. Values are compared using IEquatable{T}.Equals(T).

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

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

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

Reports the zero-based index of the last occurrence of the specified value in the current span.

C#
public static int LastIndexOf(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 span and value are compared.

Returns

The index of the last occurrence of the value in the span.

Applies to

.NET 10 e outras versións
Produto Versións
.NET Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10

LastIndexOf<T>(ReadOnlySpan<T>, ReadOnlySpan<T>)

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

Searches for the specified sequence and returns the index of its last occurrence. Values are compared using IEquatable{T}.Equals(T).

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

Type Parameters

T

The type of the span and value.

Parameters

span
ReadOnlySpan<T>

The span to search.

value
ReadOnlySpan<T>

The sequence to search for.

Returns

The index of the last occurrence of the value in the span. If not found, returns -1.

Applies to

.NET 10 e outras versións
Produto Versións
.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

LastIndexOf<T>(ReadOnlySpan<T>, T)

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

Searches for the specified value and returns the index of its last occurrence. Values are compared using IEquatable{T}.Equals(T).

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

Type Parameters

T

The type of the span and value.

Parameters

span
ReadOnlySpan<T>

The span to search.

value
T

The value to search for.

Returns

The index of the last occurrence of the value in the span. If not found, returns -1.

Applies to

.NET 10 e outras versións
Produto Versións
.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

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

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

Searches for the specified sequence and returns the index of its last occurrence. Values are compared using IEquatable{T}.Equals(T).

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

Type Parameters

T

The type of the span and value.

Parameters

span
Span<T>

The span to search.

value
ReadOnlySpan<T>

The sequence to search for.

Returns

The index of the last occurrence of the value in the span. If not found, returns -1.

Attributes

Applies to

.NET 10 e outras versións
Produto Versións
.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

LastIndexOf<T>(Span<T>, T)

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

Searches for the specified value and returns the index of its last occurrence. Values are compared using IEquatable{T}.Equals(T).

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

Type Parameters

T

The type of the span and value.

Parameters

span
Span<T>

The span to search.

value
T

The value to search for.

Returns

The index of the last occurrence of the value in the span. If not found, returns -1.

Attributes

Applies to

.NET 10 e outras versións
Produto Versións
.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

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

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

Type Parameters

T

Parameters

Returns

Applies to

.NET 10
Produto Versións
.NET 10

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

C#
public static int LastIndexOf<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
Produto Versións
.NET 10