this question has answer here:
- linq 2 collection simultaneously 3 answers
so have few pieces of code stuff like
list<parameterinfo> theseparams = this.action.getparameters().orderby(p => p.name).tolist(), otherparams = other.action.getparameters().orderby(p => p.name).tolist(); if(theseparams.count != otherparams.count) return false; for(int = 0; < theseparams.count; ++i) { parameterinfo thisparam = theseparams[i], otherparam = otherparams[i]; if(thisparam.name != otherparam.name) return false; } return true;
and i'm wondering if instead there's compact way iterate through lists @ once?
sure use enumerable.zip
, enumerable.all
.
return theseparams.count == otherparams.count && theseparams.zip(otherparams, (t,o) => new {these = t, other =o}) .all(x => x.these.name == x.other.name);
Comments
Post a Comment