c# - Is it possible for a 'foreach' loop to have a condition check? -
if have foreach
loop, there way check boolean well?
i don't want check once inside foreach()
, break example. want foreach
on collection , @ same time evaluate if true.
for example, don't want do:
ienumerable<job> jobs = currentjobs; foreach(job job in jobs) { if (found) break; }
you turn loop.
for (i = 0; < jobs.count && booleantrue; i++) { // lot of great stuff }
you need change jobs ienumerable
ilist
. think ilist
serve purposes better. ienumerable
lazy evaluates elements before need them , doesn't include associated collection helper methods.
Comments
Post a Comment