Skip an item in a foreach

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

How would I skip an item in a foreach loop without breaking out of the loop
altogether?

foreach(SearchResult resCol1 in resCol)
{
string myString = resCol1.Properties["name"][0].ToString();
if (myString.IndexOf("badstuff") > 0)
//go to next item
…
}
 
Okay, that must have been the only one I did not try... Thanks!

Peter Rilling said:
if( ... ){
continue;
}


James said:
How would I skip an item in a foreach loop without breaking out of the
loop
altogether?

foreach(SearchResult resCol1 in resCol)
{
string myString = resCol1.Properties["name"][0].ToString();
if (myString.IndexOf("badstuff") > 0)
//go to next item
.
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top