Why do we use index in "where clause"? Is it an auto generated number ans starts from zero? Simple example would be really helpful.
var query =... Where((p,index)..)
Why do we use index in "where clause"? Is it an auto generated number ans starts from zero? Simple example would be really helpful.
var query =... Where((p,index)..)
The index should refer to the index of the current item in the collection (the zero based iteration).
There is a simple example on this page.
Yes, it is an auto-generated number that starts from zero.
Use it whenever you need access to the index in your query.
var alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
var evenLetters = alphabet.Where((p, index) => (index % 2) == 1);
var oddLetters = alphabet.Where((p, index) => (index % 2) == 0);
var oddElements = query.Where((p, index) => index % 2 == 1);