Note

Access to this page requires authorization. You can try signing in or .

Access to this page requires authorization. You can try .

MemoryExtensions.IndexOfAny Method

Definition

Namespace:
System
Assemblies:
netstandard.dll, System.Memory.dll
Assembly:
System.Memory.dll
Assembly:
netstandard.dll

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

Name Description
IndexOfAny(ReadOnlySpan<Char>, SearchValues<String>)

Searches for the first index of any of the specified substring values.

IndexOfAny(Span<Char>, SearchValues<String>)

Searches for the first index of any of the specified substring values.

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

Searches for the first index of any of the specified values.

IndexOfAny<T>(Span<T>, T, T, T)

Searches for the first index of any of the specified values.

IndexOfAny<T>(ReadOnlySpan<T>, T, T, T)

Searches for the first index of any of the specified values.

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

Searches for the first index of any of the specified values.

IndexOfAny<T>(ReadOnlySpan<T>, T, T)

Searches for the first index of either of the specified values.

IndexOfAny<T>(Span<T>, T, T)

Searches for the first index of any of the specified values.

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

Searches for the first index of any of the specified values.

IndexOfAny<T>(Span<T>, SearchValues<T>)

Searches for the first index of any of the specified values.

IndexOfAny<T>(ReadOnlySpan<T>, ReadOnlySpan<T>)

Searches for the first index of any of the specified values.

IndexOfAny<T>(ReadOnlySpan<T>, SearchValues<T>)

Searches for the first index of any of the specified values.

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

Searches for the first index of any of the specified values.

IndexOfAny(ReadOnlySpan<Char>, SearchValues<String>)

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

Searches for the first index of any of the specified substring values.

public:
[System::Runtime::CompilerServices::Extension]
 static int IndexOfAny(ReadOnlySpan<char> span, System::Buffers::SearchValues<System::String ^> ^ values);
public static int IndexOfAny(this ReadOnlySpan<char> span, System.Buffers.SearchValues<string> values);
static member IndexOfAny : ReadOnlySpan<char> * System.Buffers.SearchValues<string> -> int
<Extension()>
Public Function IndexOfAny (span As ReadOnlySpan(Of Char), values As SearchValues(Of String)) As Integer

Parameters

span
ReadOnlySpan<Char>

The span to search.

values
SearchValues<String>

The set of values to search for.

Returns

The first index of any of the specified values, or -1 if none are found.

Applies to

IndexOfAny(Span<Char>, SearchValues<String>)

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

Searches for the first index of any of the specified substring values.

public:
[System::Runtime::CompilerServices::Extension]
 static int IndexOfAny(Span<char> span, System::Buffers::SearchValues<System::String ^> ^ values);
[System.Runtime.CompilerServices.OverloadResolutionPriority(-1)]
public static int IndexOfAny(this Span<char> span, System.Buffers.SearchValues<string> values);
public static int IndexOfAny(this Span<char> span, System.Buffers.SearchValues<string> values);
[<System.Runtime.CompilerServices.OverloadResolutionPriority(-1)>]
static member IndexOfAny : Span<char> * System.Buffers.SearchValues<string> -> int
static member IndexOfAny : Span<char> * System.Buffers.SearchValues<string> -> int
<Extension()>
Public Function IndexOfAny (span As Span(Of Char), values As SearchValues(Of String)) As Integer

Parameters

span
Span<Char>

The span to search.

values
SearchValues<String>

The set of values to search for.

Returns

The first index of any of the specified values, or -1 if none are found.

Attributes

Applies to

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

Source:
MemoryExtensions.cs
Source:
MemoryExtensions.cs

Searches for the first index of any of the specified values.

public static int IndexOfAny<T>(this ReadOnlySpan<T> span, T value0, T value1, T value2, System.Collections.Generic.IEqualityComparer<T>? comparer = default);
static member IndexOfAny : ReadOnlySpan<'T> * 'T * 'T * 'T * System.Collections.Generic.IEqualityComparer<'T> -> int
<Extension()>
Public Function IndexOfAny(Of T) (span As ReadOnlySpan(Of T), value0 As T, value1 As T, value2 As T, Optional comparer As IEqualityComparer(Of T) = Nothing) As Integer

Type Parameters

T

Parameters

span
ReadOnlySpan<T>

The span to search.

value0
T

The first value to search for.

value1
T

The second value to search for.

value2
T

The third 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 first index of any of the specified values. If not found, returns -1.

Remarks

This method is similar to calling IndexOf several times with the logical OR operator.

Applies to

IndexOfAny<T>(Span<T>, T, T, T)

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

Searches for the first index of any of the specified values.

public:
generic <typename T>
 where T : IEquatable<T>[System::Runtime::CompilerServices::Extension]
 static int IndexOfAny(Span<T> span, T value0, T value1, T value2);
[System.Runtime.CompilerServices.OverloadResolutionPriority(-1)]
public static int IndexOfAny<T>(this Span<T> span, T value0, T value1, T value2) where T : IEquatable<T>;
public static int IndexOfAny<T>(this Span<T> span, T value0, T value1, T value2) where T : IEquatable<T>;
[<System.Runtime.CompilerServices.OverloadResolutionPriority(-1)>]
static member IndexOfAny : Span<'T (requires 'T :> IEquatable<'T>)> * 'T * 'T * 'T -> int (requires 'T :> IEquatable<'T>)
static member IndexOfAny : Span<'T (requires 'T :> IEquatable<'T>)> * 'T * 'T * 'T -> int (requires 'T :> IEquatable<'T>)
<Extension()>
Public Function IndexOfAny(Of T As IEquatable(Of T)) (span As Span(Of T), value0 As T, value1 As T, value2 As T) As Integer

Type Parameters

T

The type of the span and values.

Parameters

span
Span<T>

The span to search.

value0
T

The first value to search for.

value1
T

The second value to search for.

value2
T

The third value to search for.

Returns

The first index of the occurrence of any of the values in the span. If not found, returns -1.

Attributes

Remarks

This method is similar to calling IndexOf several times with the logical OR operator.

Applies to

IndexOfAny<T>(ReadOnlySpan<T>, T, T, T)

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

Searches for the first index of any of the specified values.

public:
generic <typename T>
 where T : IEquatable<T>[System::Runtime::CompilerServices::Extension]
 static int IndexOfAny(ReadOnlySpan<T> span, T value0, T value1, T value2);
public static int IndexOfAny<T>(this ReadOnlySpan<T> span, T value0, T value1, T value2) where T : IEquatable<T>;
static member IndexOfAny : ReadOnlySpan<'T (requires 'T :> IEquatable<'T>)> * 'T * 'T * 'T -> int (requires 'T :> IEquatable<'T>)
<Extension()>
Public Function IndexOfAny(Of T As IEquatable(Of T)) (span As ReadOnlySpan(Of T), value0 As T, value1 As T, value2 As T) As Integer

Type Parameters

T

The type of the span and values.

Parameters

span
ReadOnlySpan<T>

The span to search.

value0
T

The first value to search for.

value1
T

The second value to search for.

value2
T

The third value to search for.

Returns

The first index of the occurrence of any of the values in the span. If not found, returns -1.

Remarks

This method is similar to calling IndexOf several times with the logical OR operator.

Applies to

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

Source:
MemoryExtensions.cs
Source:
MemoryExtensions.cs

Searches for the first index of any of the specified values.

public static int IndexOfAny<T>(this ReadOnlySpan<T> span, T value0, T value1, System.Collections.Generic.IEqualityComparer<T>? comparer = default);
static member IndexOfAny : ReadOnlySpan<'T> * 'T * 'T * System.Collections.Generic.IEqualityComparer<'T> -> int
<Extension()>
Public Function IndexOfAny(Of T) (span As ReadOnlySpan(Of T), value0 As T, value1 As T, Optional comparer As IEqualityComparer(Of T) = Nothing) As Integer

Type Parameters

T

Parameters

span
ReadOnlySpan<T>

The span to search.

value0
T

The first value to search for.

value1
T

The second 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 first index of any of the specified values. If not found, returns -1.

Remarks

This method is similar to calling IndexOf several times with the logical OR operator.

Applies to

IndexOfAny<T>(ReadOnlySpan<T>, T, T)

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

Searches for the first index of either of the specified values.

public:
generic <typename T>
 where T : IEquatable<T>[System::Runtime::CompilerServices::Extension]
 static int IndexOfAny(ReadOnlySpan<T> span, T value0, T value1);
public static int IndexOfAny<T>(this ReadOnlySpan<T> span, T value0, T value1) where T : IEquatable<T>;
static member IndexOfAny : ReadOnlySpan<'T (requires 'T :> IEquatable<'T>)> * 'T * 'T -> int (requires 'T :> IEquatable<'T>)
<Extension()>
Public Function IndexOfAny(Of T As IEquatable(Of T)) (span As ReadOnlySpan(Of T), value0 As T, value1 As T) As Integer

Type Parameters

T

The type of the span and values.

Parameters

span
ReadOnlySpan<T>

The span to search.

value0
T

The first value to search for.

value1
T

The second value to search for.

Returns

The first index of the occurrence of any of the values in the span. If not found, returns -1.

Remarks

This method is similar to calling IndexOf several times with the logical OR operator.

Applies to

IndexOfAny<T>(Span<T>, T, T)

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

Searches for the first index of any of the specified values.

public:
generic <typename T>
 where T : IEquatable<T>[System::Runtime::CompilerServices::Extension]
 static int IndexOfAny(Span<T> span, T value0, T value1);
[System.Runtime.CompilerServices.OverloadResolutionPriority(-1)]
public static int IndexOfAny<T>(this Span<T> span, T value0, T value1) where T : IEquatable<T>;
public static int IndexOfAny<T>(this Span<T> span, T value0, T value1) where T : IEquatable<T>;
[<System.Runtime.CompilerServices.OverloadResolutionPriority(-1)>]
static member IndexOfAny : Span<'T (requires 'T :> IEquatable<'T>)> * 'T * 'T -> int (requires 'T :> IEquatable<'T>)
static member IndexOfAny : Span<'T (requires 'T :> IEquatable<'T>)> * 'T * 'T -> int (requires 'T :> IEquatable<'T>)
<Extension()>
Public Function IndexOfAny(Of T As IEquatable(Of T)) (span As Span(Of T), value0 As T, value1 As T) As Integer

Type Parameters

T

The type of the span and values.

Parameters

span
Span<T>

The span to search.

value0
T

The first value to search for.

value1
T

The second value to search for.

Returns

The first index of the occurrence of any of the values in the span. If not found, returns -1.

Attributes

Remarks

This method is similar to calling IndexOf several times with the logical OR operator.

Applies to

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

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

Searches for the first index of any of the specified values.

public:
generic <typename T>
 where T : IEquatable<T>[System::Runtime::CompilerServices::Extension]
 static int IndexOfAny(Span<T> span, ReadOnlySpan<T> values);
[System.Runtime.CompilerServices.OverloadResolutionPriority(-1)]
public static int IndexOfAny<T>(this Span<T> span, ReadOnlySpan<T> values) where T : IEquatable<T>;
public static int IndexOfAny<T>(this Span<T> span, ReadOnlySpan<T> values) where T : IEquatable<T>;
[<System.Runtime.CompilerServices.OverloadResolutionPriority(-1)>]
static member IndexOfAny : Span<'T (requires 'T :> IEquatable<'T>)> * ReadOnlySpan<'T (requires 'T :> IEquatable<'T>)> -> int (requires 'T :> IEquatable<'T>)
static member IndexOfAny : Span<'T (requires 'T :> IEquatable<'T>)> * ReadOnlySpan<'T (requires 'T :> IEquatable<'T>)> -> int (requires 'T :> IEquatable<'T>)
<Extension()>
Public Function IndexOfAny(Of T As IEquatable(Of T)) (span As Span(Of T), values As ReadOnlySpan(Of T)) As Integer

Type Parameters

T

The type of the span and values.

Parameters

span
Span<T>

The span to search.

values
ReadOnlySpan<T>

The set of values to search for.

Returns

The first index of the occurrence of any of the values in the span. If not found, returns -1.

Attributes

Remarks

This method is similar to calling IndexOf several times with the logical OR operator.

Applies to

IndexOfAny<T>(Span<T>, SearchValues<T>)

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

Searches for the first index of any of the specified values.

public:
generic <typename T>
 where T : IEquatable<T>[System::Runtime::CompilerServices::Extension]
 static int IndexOfAny(Span<T> span, System::Buffers::SearchValues<T> ^ values);
[System.Runtime.CompilerServices.OverloadResolutionPriority(-1)]
public static int IndexOfAny<T>(this Span<T> span, System.Buffers.SearchValues<T> values) where T : IEquatable<T>;
public static int IndexOfAny<T>(this Span<T> span, System.Buffers.SearchValues<T> values) where T : IEquatable<T>;
[<System.Runtime.CompilerServices.OverloadResolutionPriority(-1)>]
static member IndexOfAny : Span<'T (requires 'T :> IEquatable<'T>)> * System.Buffers.SearchValues<'T (requires 'T :> IEquatable<'T>)> -> int (requires 'T :> IEquatable<'T>)
static member IndexOfAny : Span<'T (requires 'T :> IEquatable<'T>)> * System.Buffers.SearchValues<'T (requires 'T :> IEquatable<'T>)> -> int (requires 'T :> IEquatable<'T>)
<Extension()>
Public Function IndexOfAny(Of T As IEquatable(Of T)) (span As Span(Of T), values As SearchValues(Of T)) As Integer

Type Parameters

T

Parameters

span
Span<T>

The span to search.

values
SearchValues<T>

The set of values to search for.

Returns

The first index of any of the specified values, or -1 if none are found.

Attributes

Remarks

This method is similar to calling IndexOf several times with the logical OR operator.

Applies to

IndexOfAny<T>(ReadOnlySpan<T>, ReadOnlySpan<T>)

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

Searches for the first index of any of the specified values.

public:
generic <typename T>
 where T : IEquatable<T>[System::Runtime::CompilerServices::Extension]
 static int IndexOfAny(ReadOnlySpan<T> span, ReadOnlySpan<T> values);
public static int IndexOfAny<T>(this ReadOnlySpan<T> span, ReadOnlySpan<T> values) where T : IEquatable<T>;
static member IndexOfAny : ReadOnlySpan<'T (requires 'T :> IEquatable<'T>)> * ReadOnlySpan<'T (requires 'T :> IEquatable<'T>)> -> int (requires 'T :> IEquatable<'T>)
<Extension()>
Public Function IndexOfAny(Of T As IEquatable(Of T)) (span As ReadOnlySpan(Of T), values As ReadOnlySpan(Of T)) As Integer

Type Parameters

T

The type of the span and values.

Parameters

span
ReadOnlySpan<T>

The span to search.

values
ReadOnlySpan<T>

The set of values to search for.

Returns

The first index of the occurrence of any of the values in the span. If not found, returns -1.

Remarks

This method is similar to calling IndexOf several times with the logical OR operator.

Applies to

IndexOfAny<T>(ReadOnlySpan<T>, SearchValues<T>)

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

Searches for the first index of any of the specified values.

public:
generic <typename T>
 where T : IEquatable<T>[System::Runtime::CompilerServices::Extension]
 static int IndexOfAny(ReadOnlySpan<T> span, System::Buffers::SearchValues<T> ^ values);
public static int IndexOfAny<T>(this ReadOnlySpan<T> span, System.Buffers.SearchValues<T> values) where T : IEquatable<T>;
static member IndexOfAny : ReadOnlySpan<'T (requires 'T :> IEquatable<'T>)> * System.Buffers.SearchValues<'T (requires 'T :> IEquatable<'T>)> -> int (requires 'T :> IEquatable<'T>)
<Extension()>
Public Function IndexOfAny(Of T As IEquatable(Of T)) (span As ReadOnlySpan(Of T), values As SearchValues(Of T)) As Integer

Type Parameters

T

Parameters

span
ReadOnlySpan<T>

The span to search.

values
SearchValues<T>

The set of values to search for.

Returns

The first index of any of the specified values, or -1 if none are found.

Remarks

This method is similar to calling IndexOf several times with the logical OR operator.

Applies to

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

Source:
MemoryExtensions.cs
Source:
MemoryExtensions.cs

Searches for the first index of any of the specified values.

public static int IndexOfAny<T>(this ReadOnlySpan<T> span, ReadOnlySpan<T> values, System.Collections.Generic.IEqualityComparer<T>? comparer = default);
static member IndexOfAny : ReadOnlySpan<'T> * ReadOnlySpan<'T> * System.Collections.Generic.IEqualityComparer<'T> -> int
<Extension()>
Public Function IndexOfAny(Of T) (span As ReadOnlySpan(Of T), values As ReadOnlySpan(Of T), Optional comparer As IEqualityComparer(Of T) = Nothing) As Integer

Type Parameters

T

Parameters

span
ReadOnlySpan<T>

The span to search.

values
ReadOnlySpan<T>

The set of values 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 first index of any of the specified values. If not found, returns -1.

Remarks

This method is similar to calling IndexOf several times with the logical OR operator.

Applies to


Feedback

Was this page helpful?