Loop condition can be any bool expression

image_pdfimage_print
   

/*
C#: The Complete Reference 
by Herbert Schildt 

Publisher: Osborne/McGraw-Hill (March 8, 2002)
ISBN: 0072134852
*/
// Loop condition can be any bool expression. 
using System; 
 
public class forDemo {    
  public static void Main() {    
    int i, j; 
    bool done = false; 
 
    for(i=0, j=100; !done; i++, j--) { 
 
      if(i*i >= j) done = true; 
 
      Console.WriteLine("i, j: " + i + " " + j); 
    } 
 
  }    
}