c# - Get index of lines that match my linq -


i have linq statement , know if possible indicies of lines match statement? here is:

var result = list3.where(middle => list4.any(x => x == middle.middle.category1)).select(obj => new { obj, dt = datetime.parseexact(obj.leftcolumn, dateformat, cultureinfo.invariantculture) })            .where(x => x.dt >= datetimepickerchoice1 && x.dt <= datetimepickerchoice2)            .select(x => x.obj).tolist(); 

you can use overload of select (or where) projects index of element:

var result = list3.select((middle, index) => new{ middle, index })     .where(x => list4.any(xx => xx == x.middle.middle.category1))     .select(x => new { x.middle, x.index, dt = datetime.parseexact(x.middle.leftcolumn, dateformat, cultureinfo.invariantculture) })     .where(x => x.dt >= czas11 && x.dt <= czas22)     .select(x => x.index)     .tolist(); 

side-note: consider change variable names more meaningful. unreadable.


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -