ch4_05.cs

来自「《c#技术内幕代码》」· CS 代码 · 共 41 行

CS
41
字号
using System;
class CH4_5
{
   public static void Main()
   {
      // First, a simple do loop that
      // increments a counter
      int i = 0;
      Console.WriteLine("Loop 1:");
      do
      {
         Console.WriteLine("I = {0}", i );
	 i ++;
      } while ( i < 5 );
      
      // Next, the same case, but using a 
      // boolean rather than an index
      
      i = 0;
      Boolean done = false;
      Console.WriteLine("\nLoop 2:");
      do
      {
         Console.WriteLine("I = {0}", i );
	 i ++;
         if ( i > 5 )
	    done = true;
      } while ( !done );
      
      // Finally, a conditional that is true before
      // we get into the loop
      do 
      {
         Console.WriteLine("Into Loop 3");
      } while ( !done );
      
   }
}

      

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?