473,396 Members | 2,014 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,396 software developers and data experts.

How do I jump to the Next row in a foreach

C#

I am iterating through a collection of rows thus:

foreach(DataRow myRow in dsTable.Table[0].Rows)
{
...........
}

in this loop I have some conditions and when one is met I dont want it to
procede down the code, I want it to go back to the top of the loop and
process the next row in the collection. How do I do this?

In a previous life when programming with Progress you could do this:

myloop:
FOR EACH row:

IF myconditionismet THEN
NEXT myloop

.........

END.

This is the kind of thing I am after.

Thanks

Steve
Feb 9 '06 #1
4 4202
"continue"

"Steve" <St***@discussions.microsoft.com> wrote in message
news:F8**********************************@microsof t.com...
C#

I am iterating through a collection of rows thus:

foreach(DataRow myRow in dsTable.Table[0].Rows)
{
..........
}

in this loop I have some conditions and when one is met I dont want it to
procede down the code, I want it to go back to the top of the loop and
process the next row in the collection. How do I do this?

In a previous life when programming with Progress you could do this:

myloop:
FOR EACH row:

IF myconditionismet THEN
NEXT myloop

........

END.

This is the kind of thing I am after.

Thanks

Steve

Feb 9 '06 #2

I would just put the optional code in an if() statement block.
foreach ()

{

Do();

Do2();
Do3();

if(x)
{
do4();
do5();

}

}
Steve wrote:
C#

I am iterating through a collection of rows thus:

foreach(DataRow myRow in dsTable.Table[0].Rows)
{
..........
}

in this loop I have some conditions and when one is met I dont want it to
procede down the code, I want it to go back to the top of the loop and
process the next row in the collection. How do I do this?

In a previous life when programming with Progress you could do this:

myloop:
FOR EACH row:

IF myconditionismet THEN
NEXT myloop

........

END.

This is the kind of thing I am after.

Thanks

Steve

Feb 9 '06 #3

If I put that in a case statement condition -- would I have to also use
break; ?

or would it be

continue;
break;


Peter Rilling wrote:
"continue"

"Steve" <St***@discussions.microsoft.com> wrote in message
news:F8**********************************@microsof t.com...
C#

I am iterating through a collection of rows thus:

foreach(DataRow myRow in dsTable.Table[0].Rows)
{
..........
}

in this loop I have some conditions and when one is met I dont want it to
procede down the code, I want it to go back to the top of the loop and
process the next row in the collection. How do I do this?

In a previous life when programming with Progress you could do this:

myloop:
FOR EACH row:

IF myconditionismet THEN
NEXT myloop

........

END.

This is the kind of thing I am after.

Thanks

Steve


Feb 9 '06 #4
The continue statement passes control to the next iteration of the enclosing
iteration statement in which it appears.

The switch has the following form:

switch (expression)
{
case <constant-expression>:
<statement>
<jump-statement>
[default:
<statement>
<jump-statement>]
}

A jump statement that transfers control out of the case body and may be
break, continue, default, goto or return

So no break after continue;

I hope that helps.

Regards,
Arnd Hurlbrink
"John Bailo" <ja*****@texeme.com> wrote in message
news:43**************@texeme.com...

If I put that in a case statement condition -- would I have to also use
break; ?

or would it be

continue;
break;


Peter Rilling wrote:
"continue"

"Steve" <St***@discussions.microsoft.com> wrote in message
news:F8**********************************@microsof t.com...
C#

I am iterating through a collection of rows thus:

foreach(DataRow myRow in dsTable.Table[0].Rows)
{
..........
}

in this loop I have some conditions and when one is met I dont want it to
procede down the code, I want it to go back to the top of the loop and
process the next row in the collection. How do I do this?

In a previous life when programming with Progress you could do this:

myloop:
FOR EACH row:

IF myconditionismet THEN
NEXT myloop

........

END.

This is the kind of thing I am after.

Thanks

Steve



Feb 13 '06 #5

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

Similar topics

2
by: Christian | last post by:
Hi, I have a button on an html-page. how do I jump to a next html-page when clicking on the button ? sample code : function btnNext_onclick() { here do I want to jump to page2.html but how...
5
by: Arjen | last post by:
Hello, I have a this: foreach ( string s in myArray ) { if ( s == ""test") { } }
4
by: Xero | last post by:
Hello. I am using vb.net. I have a series of textboxes and each of them can contain one letter only. How can I get the cursor jump to the next textbox after one has been filled with a letter?...
1
by: Xero | last post by:
I have a series of textboxes and each of them can contain one letter only. How can I get the cursor jump to the next textbox after one has been filled with a letter? I'd like to write this in...
9
by: paul c | last post by:
Apologies if I'm sending this to the wrong group. If so I'd be grateful if somebody could point me to the right one. I'm using microsoft visual c++ 6.0 compiler. My code is C, I just use the...
1
by: AA Arens | last post by:
I have a button containing the VB command Me.Notes = Me.Notes & Format(Date, "dd-mm-yyyy") to have a date filled in a field. I want it automatically jump to the next field, after the date is...
4
by: robert d via AccessMonster.com | last post by:
When my app starts up, it creates a temporary database. This temp database is created from a 'model' database that is in the same folder as the application. Because there is a model, the creation...
2
by: Leo | last post by:
I set HasMorePages to true, but it doesn't let me jump to next page. (Of course, if I remove the HasMorePages = false in my if statement, it will create hundreds of pages). Any suggestion? Thanks...
1
by: =?Utf-8?B?bGlhbnF0bGl0?= | last post by:
Is using a jump statement more faster than using if statement with a jump statement example for(int i=0; i < 10; i++) { if(a == null) {
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.