c# - Get item index of a list within Select statement -


i need index item list position after grouping

var result = in items              group i.name g              select new { groupname = g.key,                            index = //need index of item                         }; 

how item index of list using linq/lambda?

i'm not 100% sure you're trying achieve, advice use methods instead of syntax-based query.

var results = items.groupby(x => x.name)                    .select((g, i) => new { product = g.key, index = }); 

or if you'd indexes source lift items within every group:

var results = items.select((x, i) => new { x, })                    .groupby(x => x.x.name)                    .select(g => new {                                    product = g.key,                                    indexes = g.select(x => x.i).tolist()                                }); 

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 -