I found this code explaining the flow control continue
.
string [] nomes = new string[] { "Macoratti", "Miriam", "Pedro"};
foreach (string nome in nomes)
{
if (nome == "Miriam")
continue;
Console.WriteLine (nome);
}
The continue command is also used in loops (
while, for, etc.
) when in executing the continue command will move the execution to the next iteration in the loop without executing the lines of code after continue.
Output:
Macoratti
Pedro
- How does
continue
work? - In what situations is your usage useful?
- Why does the output not print the name Miriam ?