One, the normal for loop we have been exposed to a lot, as below, we all understand
int [] tt = {1,2,3,4,5,6 }; for (int16; i++) { Console.WriteLine (tt[i]); }
Two, but for (;;) What does it actually mean?
Meaning: For parentheses, the content before the first semicolon is executed before the first loop, and the contents before the second semicolon are judged before each execution (if the value of the expression is true, then the loop body is executed, and if False, then the loop body is jumped out)
Third, do you think it is so common to write about it? Well, let's do some expansion, the following code
usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Text;usingSystem.Threading.Tasks;namespacew{classProgram {Static voidMain (string[] args) { intt2 =0; intT1 =0; for(Demo.first (refT1); Demo.scend (T1,refT2); ) {Console.WriteLine (T2); } } } Public classDemo { Public Static intj =5; Public Static BOOLFirst (ref intT1) {T1=1; return false; } Public Static BOOLScend (intT1,ref intT2) { if(J >0) {J= J-T1; T2=J; return true; } Else { return false; } } }}
Three, in the above code we see for (Demo.first (); Demo.scend (1,ref te); ) is to call two methods in a semicolon, is not the same as usual use?? Then why do you use it this way? We are based on for (;;) Meaning to parse.
1, the content before the first semicolon is executed before the first loop, and the first semicolon does not determine true and false, so the definition returns false and does not jump out of the loop
2, the second semicolon before the content is to be judged before each execution (if the value of the expression is true, then the loop body, if false, then jump out of the loop body)
C#for (;;) What does that mean?