MemoryExtensions.IndexOf 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
| IndexOf(ReadOnlySpan<Char>, ReadOnlySpan<Char>, StringComparison) |
Reports the zero-based index of the first occurrence of the specified |
| IndexOf<T>(ReadOnlySpan<T>, ReadOnlySpan<T>) |
Searches for the specified sequence and returns the index of its first occurrence. |
| IndexOf<T>(ReadOnlySpan<T>, T) |
Searches for the specified value and returns the index of its first occurrence. |
| IndexOf<T>(Span<T>, ReadOnlySpan<T>) |
Searches for the specified sequence and returns the index of its first occurrence. |
| IndexOf<T>(Span<T>, T) |
Searches for the specified value and returns the index of its first occurrence. |
| IndexOf<T>(ReadOnlySpan<T>, ReadOnlySpan<T>, IEqualityComparer<T>) |
Searches for the specified sequence and returns the index of its first occurrence. |
| IndexOf<T>(ReadOnlySpan<T>, T, IEqualityComparer<T>) |
Searches for the specified value and returns the index of its first occurrence. |
IndexOf(ReadOnlySpan<Char>, ReadOnlySpan<Char>, StringComparison)
Reports the zero-based index of the first occurrence of the specified value in the current span.
public:
[System::Runtime::CompilerServices::Extension]
static int IndexOf(ReadOnlySpan<char> span, ReadOnlySpan<char> value, StringComparison comparisonType);
public static int IndexOf(this ReadOnlySpan<char> span, ReadOnlySpan<char> value, StringComparison comparisonType);
static member IndexOf : ReadOnlySpan<char> * ReadOnlySpan<char> * StringComparison -> int
<Extension()>
Public Function IndexOf (span As ReadOnlySpan(Of Char), value As ReadOnlySpan(Of Char), comparisonType As StringComparison) As Integer
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 occurrence of the value in the span.
Applies to
IndexOf<T>(ReadOnlySpan<T>, ReadOnlySpan<T>)
- Source:
- MemoryExtensions.cs
- Source:
- MemoryExtensions.cs
- Source:
- MemoryExtensions.cs
- Source:
- MemoryExtensions.cs
Searches for the specified sequence and returns the index of its first occurrence.
public:
generic <typename T>
where T : IEquatable<T>[System::Runtime::CompilerServices::Extension]
static int IndexOf(ReadOnlySpan<T> span, ReadOnlySpan<T> value);
public static int IndexOf<T>(this ReadOnlySpan<T> span, ReadOnlySpan<T> value) where T : IEquatable<T>;
static member IndexOf : ReadOnlySpan<'T (requires 'T :> IEquatable<'T>)> * ReadOnlySpan<'T (requires 'T :> IEquatable<'T>)> -> int (requires 'T :> IEquatable<'T>)
<Extension()>
Public Function IndexOf(Of T As IEquatable(Of T)) (span As ReadOnlySpan(Of T), value As ReadOnlySpan(Of T)) As Integer
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 occurrence of the value in the span. If not found, returns -1.
Remarks
Values are compared using IEquatable{T}.Equals(T).
Applies to
IndexOf<T>(ReadOnlySpan<T>, T)
- Source:
- MemoryExtensions.cs
- Source:
- MemoryExtensions.cs
- Source:
- MemoryExtensions.cs
- Source:
- MemoryExtensions.cs
Searches for the specified value and returns the index of its first occurrence.
public:
generic <typename T>
where T : IEquatable<T>[System::Runtime::CompilerServices::Extension]
static int IndexOf(ReadOnlySpan<T> span, T value);
public static int IndexOf<T>(this ReadOnlySpan<T> span, T value) where T : IEquatable<T>;
static member IndexOf : ReadOnlySpan<'T (requires 'T :> IEquatable<'T>)> * 'T -> int (requires 'T :> IEquatable<'T>)
<Extension()>
Public Function IndexOf(Of T As IEquatable(Of T)) (span As ReadOnlySpan(Of T), value As T) As Integer
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 occurrence of the value in the span. If not found, returns -1.
Remarks
Values are compared using IEquatable{T}.Equals(T).
Applies to
IndexOf<T>(Span<T>, ReadOnlySpan<T>)
- Source:
- MemoryExtensions.cs
- Source:
- MemoryExtensions.cs
- Source:
- MemoryExtensions.cs
- Source:
- MemoryExtensions.cs
Searches for the specified sequence and returns the index of its first occurrence.
public:
generic <typename T>
where T : IEquatable<T>[System::Runtime::CompilerServices::Extension]
static int IndexOf(Span<T> span, ReadOnlySpan<T> value);
[System.Runtime.CompilerServices.OverloadResolutionPriority(-1)]
public static int IndexOf<T>(this Span<T> span, ReadOnlySpan<T> value) where T : IEquatable<T>;
public static int IndexOf<T>(this Span<T> span, ReadOnlySpan<T> value) where T : IEquatable<T>;
[<System.Runtime.CompilerServices.OverloadResolutionPriority(-1)>]
static member IndexOf : Span<'T (requires 'T :> IEquatable<'T>)> * ReadOnlySpan<'T (requires 'T :> IEquatable<'T>)> -> int (requires 'T :> IEquatable<'T>)
static member IndexOf : Span<'T (requires 'T :> IEquatable<'T>)> * ReadOnlySpan<'T (requires 'T :> IEquatable<'T>)> -> int (requires 'T :> IEquatable<'T>)
<Extension()>
Public Function IndexOf(Of T As IEquatable(Of T)) (span As Span(Of T), value As ReadOnlySpan(Of T)) As Integer
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 occurrence of the value in the span. If not found, returns -1.
- Attributes
Remarks
Values are compared using IEquatable{T}.Equals(T).
Applies to
IndexOf<T>(Span<T>, T)
- Source:
- MemoryExtensions.cs
- Source:
- MemoryExtensions.cs
- Source:
- MemoryExtensions.cs
- Source:
- MemoryExtensions.cs
Searches for the specified value and returns the index of its first occurrence.
public:
generic <typename T>
where T : IEquatable<T>[System::Runtime::CompilerServices::Extension]
static int IndexOf(Span<T> span, T value);
[System.Runtime.CompilerServices.OverloadResolutionPriority(-1)]
public static int IndexOf<T>(this Span<T> span, T value) where T : IEquatable<T>;
public static int IndexOf<T>(this Span<T> span, T value) where T : IEquatable<T>;
[<System.Runtime.CompilerServices.OverloadResolutionPriority(-1)>]
static member IndexOf : Span<'T (requires 'T :> IEquatable<'T>)> * 'T -> int (requires 'T :> IEquatable<'T>)
static member IndexOf : Span<'T (requires 'T :> IEquatable<'T>)> * 'T -> int (requires 'T :> IEquatable<'T>)
<Extension()>
Public Function IndexOf(Of T As IEquatable(Of T)) (span As Span(Of T), value As T) As Integer
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 occurrence of the value in the span. If not found, returns -1.
- Attributes
Remarks
Values are compared using IEquatable{T}.Equals(T).
Applies to
IndexOf<T>(ReadOnlySpan<T>, ReadOnlySpan<T>, IEqualityComparer<T>)
- Source:
- MemoryExtensions.cs
Searches for the specified sequence and returns the index of its first occurrence.
public static int IndexOf<T>(this ReadOnlySpan<T> span, ReadOnlySpan<T> value, System.Collections.Generic.IEqualityComparer<T>? comparer = default);
static member IndexOf : ReadOnlySpan<'T> * ReadOnlySpan<'T> * System.Collections.Generic.IEqualityComparer<'T> -> int
<Extension()>
Public Function IndexOf(Of T) (span As ReadOnlySpan(Of T), value As ReadOnlySpan(Of T), Optional comparer As IEqualityComparer(Of T) = Nothing) As Integer
Type Parameters
- T
Parameters
- span
- ReadOnlySpan<T>
The span to search.
- value
- ReadOnlySpan<T>
The sequence to search for.
- 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
The index of the first occurrence of the specified sequence. If not found, returns -1.
Remarks
Values are compared using IEquatable{T}.Equals(T).
Applies to
IndexOf<T>(ReadOnlySpan<T>, T, IEqualityComparer<T>)
- Source:
- MemoryExtensions.cs
Searches for the specified value and returns the index of its first occurrence.
public static int IndexOf<T>(this ReadOnlySpan<T> span, T value, System.Collections.Generic.IEqualityComparer<T>? comparer = default);
static member IndexOf : ReadOnlySpan<'T> * 'T * System.Collections.Generic.IEqualityComparer<'T> -> int
<Extension()>
Public Function IndexOf(Of T) (span As ReadOnlySpan(Of T), value As T, Optional comparer As IEqualityComparer(Of T) = Nothing) As Integer
Type Parameters
- T
Parameters
- span
- ReadOnlySpan<T>
The span to search.
- value
- T
The value to search for.
- 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
The index of the first occurrence of the specified value. If not found, returns -1.
Remarks
Values are compared using IEquatable{T}.Equals(T).