LINQ/C#: Where & Foreach using index in a list/array
- by Andrew White
Hi,
I have a list/array and need to process certain elements, but also need the index of the element in the processing.
Example:
List Names = john, mary, john, bob, simon
Names.Where(s = s != "mary").Foreach(MyObject.setInfo(s.index, "blah")
But cannot use the "index" property with lists, inversely if the names were in an Array I cannot use…