This loop could easily be written many other ways - you could just loop while i.
This loop could easily be written many other ways - you could just loop while I 20) { continue; // Skips the rest of this loop iteration } Console. WriteLine("hello " + 1); } } Similarly, you can use break to completely break out of the loop and not process more elements, if that's more appropriate in your real case.
The natural next question is what to do if you are dealing with nested loops; break and continue will only work on the innermost loop. For discussion of this issue, see How to break out of 2 loops without a flag variable in C#? – Brian Dec 5 at 22:44.
Though it is absolutely correct to say that there are better ways to solve this problem than to use goto, I note that no one has actually answered your question. A label must label a statement. You want to go to a location that has no statement associated with it.
You can either make an empty statement with a single semicolon, or an empty block. Out1: ; } or out1: {} } But like they say, don't go there in the first place if you can avoid it.
– Brian Dec 5 at 22:39 4 @Brian: It's considered bad form by many people to have a goto at all; a goto to an empty statement is worse, and a goto to an empty statement that puts two almost-identical punctuation characters next to each other is worse still. I would avoid this idiom if possible. – Eric Lippert Dec 5 at 23:21.
Just invert your condition - also if...else might be an alternative. I assume there is other code otherwise you can just change the for loop itself to just count up to 20. For(int I = 0; I WriteLine("hello " + 1); } //other code }.
There are some other goto-like statements, you should consider using: continue goes to the next iteration of the current loop. Break leaves the current loop return exits the current method You should only consider goto if none of the above does what you want. And in my experience that's very rarely the case.It looks like you want to use continue here.
You can use the continue keyword for that: public void CountNumber() { for(int I = 0; I 20) { continue; } Console. WriteLine("hello " + 1); } } However, consider using the if instead: public void CountNumber() { for(int I = 0; I.
The same foreach - for ) – Shymep Dec 5 at 21:51.
Public void CountNumber() { for(int I = 0; I 20) { continue; } Console. WriteLine("hello " + 1); } }.
– Shymep Dec 5 at 21:50 @Shymep: yes :) – Tigran Dec 5 at 21:51 Reed Copsey and Guffa did the same :) – Shymep Dec 5 at 21:52 @Shymep: the curious thing that is everyone actually did the same mistake :) – Tigran Dec 5 at 21:52 @Shymep: corrected... – Tigran Dec 5 at 21:53.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.