Legend

Class
Struct
Enum
Interface
Delegate
Constructor
Method
Property
Event
Field

Extension method: int IndexOfSubarray<T>(this T[], T[], int, int?, IEqualityComparer<T>)

Declaration

public static int IndexOfSubarray<T>(
    this T[] sourceArray,
    T[] findWhat,
    int startIndex,
    int? sourceLength = null,
    IEqualityComparer<T> comparer = null
)

Summary

Searches the current array for a specified subarray and returns the index of the first occurrence, or -1 if not found.

Generic type parameters

TThis type parameter is not documented.

Parameters

this T[]sourceArray Array in which to search for the subarray.
T[]findWhat Subarray to search for.
intstartIndex Index in sourceArray at which to start searching.
int?sourceLength Maximum length of the source array to search starting from startIndex. The greatest index that can be returned is this minus the length of findWhat plus startIndex.
IEqualityComparer<T>comparer Optional equality comparer.

Returns

The index of the first match, or -1 if no match is found.