mercredi 25 février 2015

c# linq Is it possible to do some action before getting list


Vote count:

0





int index = 1;

var result = myList.Where(x => originalList.Contains(x.Key))
.Select(x => new Item() { Index = index++, })
.ToList();


I want to set to 1 index for each x.Key (keys are distinct).


Is it possible to do it without using ForEach and in one "line" (one expression) ?



asked 14 secs ago







c# linq Is it possible to do some action before getting list

Aucun commentaire:

Enregistrer un commentaire