Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

continue to <label> in C# like in java

Tags:

c#

label

goto

I need C# equivalent to Java’s continue ?

i have

for (String b : bar) {
    <label>
    try {
    }
    catch (EndpointNotFoundException ex) {
    continue <label>
    }
  }

how can i simulate this in C#. i need that when i get exception that i repeat code not go on.

like image 804
senzacionale Avatar asked Dec 03 '22 13:12

senzacionale


2 Answers

Use goto <label>;

like image 147
Robert Davis Avatar answered Dec 27 '22 06:12

Robert Davis


If you only need to continue to the next loop iteration, use continue.

c# also has labels (which you can jump to with goto), but please don't use them.

like image 44
Gabe Moothart Avatar answered Dec 27 '22 06:12

Gabe Moothart