Advertisement
//C# while loop example
using System;
class WhileEx1
{
public static void Main()
{
int i=0;
while(i<5)
{
Console.WriteLine("i = " + i);
i++;
}
}
}
i = 0
i = 1
i = 2
i = 3
i = 4
Advertisement
//C# An endless while loop example
using System;
class WhileEx1
{
public static void Main()
{
int i=0;
while(i<5)
{
Console.WriteLine("i = " + i);
//We have not specified the iteration part of while loop
//Hence, this while loop will run endlessly.
}
}
}
Advertisement
Advertisement
Please check our latest addition
C#, PYTHON and DJANGO
Advertisement