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
Post a Comment