c# - Retrieve the two first elements that match a condition -
i'm sure can done linq can't figure out.
var ls1 = plotter.model.series.firstordefault(x => x.isselected); var ls2 = plotter.model.series.firstordefault((x => x.isselected)&&(ls2!=ls1)); what i'm pretending obtain 2 first objects have property isselected set true.
i can't use syntax written above because compiler can't use "local variable ls2 before declared".
use where filter selected results use take select first 2 e.g.
plotter.model.series.where(x => x.isselected).take(2);
Comments
Post a Comment