0
any of can answer me why it print 0 to 8 why not 0-9
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace SoloLearn { class Program { static void Main(string[] args) { for (int i = 0; i < 10; i++) { if (i == 9 ) continue; Console.WriteLine(i); } } } }
4 Antworten
+ 5
you can see when the i reaches 9, the condition "i == 9" becomes true, so the if statement body is executed. continue means skip the rest of that iteration, so it skips the WriteLine. then "i" becomes 10 and the for loop is terminated
+ 1
It's because you skip 9th iteration of loop using "continue".
+ 1
Because when i == 9 skip the rest of the the iteration code with the continue sentence and continue with the next iteration if the for conditional comes true
0
OK I understood
thanks 😉