while loops repeatedly execute a body of code while a bool expression is true. - CSharp Language Basics

CSharp examples for Language Basics:while

Introduction

The expression is tested before the body of the loop is executed. For example:

Demo Code

using System;//from  www.  j a  va2 s.  c o  m
class Test
{
static void Main(){
     int i = 0;
     while (i < 3)
     {
       Console.WriteLine (i);
       i++;
     }
}
}

Result


Related Tutorials