asp.net mvc - skip ahead in a foreach loop c# -


if have foreach loop takes whole bunch of addresses , loops through them, there way skip first 500 entries,

something like:

foreach(var row in addresses) {   string straddr = row.address + "," + row.city + "," + row.st;   system.threading.thread.skip(500) } 

i know skip doesn't exist there can use same thing?

you can use method meaningful name:

foreach(var row in addresses.skip(500)) {     // ... } 

you need add using system.linq; since it's linq extension method.

if type of addresses doesn't implement generic ienumerable<t> interface use cast<t>. example (presuming type address):

foreach(var row in addresses.cast<address>().skip(500)) {     // ... } 

Comments

Popular posts from this blog

java - Oracle EBS .ClassNotFoundException: oracle.apps.fnd.formsClient.FormsLauncher.class ERROR -

c# - how to use buttonedit in devexpress gridcontrol -

nvd3.js - angularjs-nvd3-directives setting color in legend as well as in chart elements -