how to refer to list item with index java code example
Example: get both item and index in c#
// 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);
}