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 Foreach…
Any suggestions?
You should use a simple
forloop, like this:LINQ is not the be-all and end-all of basic loops.
If you really want to use LINQ, you need to call
Select: