Question

La requête

var q = from elem in collection
        where someCondition(elem)
        select elem;

se traduit

var q = collection.Where(elem => someCondition(elem));

Y at-il une syntaxe LINQ qui se traduirait par ce qui suit?

var q = collection.Where((elem, index) => someCondition(elem, index));
Était-ce utile?

La solution

Non il n'y a pas de syntaxe LINQ pour cela.

Un travail autour simple pourrait être:

var q = from elem in collection.Select((x,i) => new {x,i})
        where someCondition(elem.x,elem.i)
        select elem.x;
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top