Check out example codes for "get both item and index in c#". It will help you in understanding the concepts better.

Code Example 1

// add this to your namespace
public static IEnumerable<(T item, int index)> WithIndex<T>(this IEnumerable<T> source)
    return source.Select((item, index) => (item, index));

//do something like this

foreach (var (item, index) in collection.WithIndex())
    DoSomething(item, index);

Code Example 2

Array.IndexOf(arrName, searchingFor)

Learn ReactJs, React Native from