473,386 Members | 1,810 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Skip elements in a foreach loop?

How can I skip an element in a foreach loop? Break seems to jump completely
out of the foreach. I just want to move along to the next element based on
some condition.

Thanks in advance!

Adam
Mar 14 '06 #1
3 22443
"AdamM" <ad**@nospam.com> wrote in message
news:uK**************@tk2msftngp13.phx.gbl...
How can I skip an element in a foreach loop? Break seems to jump
completely out of the foreach. I just want to move along to the next
element based on some condition.
continue

Thanks in advance!

Adam

Mar 14 '06 #2
Use Continue instead of break.

Regards,
Manasi

Mar 14 '06 #3
Use Continue instead of break.

Regards,
Manasi

Mar 14 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

18
by: deko | last post by:
I have a counter file that records page hits - each hit is a UNIX timestamp in the file. But I'm only interested in page hits in the last 365 days. The below code creates an array from the file...
8
by: Brad Wood | last post by:
When I do this: foreach( Button btn in myForm.Controls ) An exception is raised when no buttons exist. I would simply expect execution to continue after the foreach loop (just as would be the...
2
by: Brett | last post by:
The following code will allow me to loop through FORM tags but not the elements in them. I may have five forms on one page. How do I loop through form elements in the forth FORM? private...
2
by: James | last post by:
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.ToString(); if...
9
by: Andreas Schmitt | last post by:
I am somewhat new to C# and I ran into a problem in a small program I am writing for teaching myself. I am handling a list ob objects and I want to delete some of them inside a loop like in: ...
29
by: Jon Slaughter | last post by:
Is it safe to remove elements from an array that foreach is working on? (normally this is not the case but not sure in php) If so is there an efficient way to handle it? (I could add the indexes to...
3
by: SM | last post by:
Hello, I have an array that holds images path of cd covers. The array looks like this: $cd = array( 589=>'sylver.jpg', 782=>'bigone.jpg', 158=>'dime.jpg' );
3
by: raghudr | last post by:
Hi all, I am parsing a .xml file.My main intention is to retrieve the name value of node "Signal":- "Name Value" which is "rag". i want to store only the <signal"name value" that is only...
2
by: virtualweb | last post by:
Hello guys: Im a perl beginner (self taught) and Im unable to get elements from an array. Here is my situation step by step: 1) A list of emails is submitted, (one email per line), through...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.