c# - Invoking .Count on a list contained inside an element of an IEnumerable -


in code have ienumerable:

ienumerable<sometype> listofsomething = methodwhichreturnsanienumerable(param 1) 

now, each element in listofsomething, contains list of else let's call listofrules. need return elements in listofsomething have >0 elements in listofrules:

var result = listofsomething.where(x => x.listofrules.count > 0); 

what mean performance? listofrules list i'm curious calling count ienumerable listofsomething in terms of whether put memory.

since listofrules list, querying count property fast, because list returns value of private field , not iterating whole collection each time. here implementation, taken here:

// read-only property describing how many elements in list. public int count {     {         contract.ensures(contract.result<int>() >= 0);         return _size;      } } 

Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -