Infinite Loop in C#
The loops in which the test conditions do not evaluate false ever tend to execute statements forever until an external force is used to end it and thus they are known as infinite loops. The for loop is traditionally used for this purpose. Since none of the three expressions that form the for loop are required, you can make an endless loop by leaving the conditional expression empty.
Example as follows.
using System;
namespace infinite_loop
{
class Program
{
static void Main(string[] args)
{
for (; ; )
Console.WriteLine("Hello World");
}
}
}
Output
// will keep printing Infinite times //
Hello world
''''''''''''''''''''''''''''
The loops in which the test conditions do not evaluate false ever tend to execute statements forever until an external force is used to end it and thus they are known as infinite loops. The for loop is traditionally used for this purpose. Since none of the three expressions that form the for loop are required, you can make an endless loop by leaving the conditional expression empty.
Example as follows.
using System;
namespace infinite_loop
{
class Program
{
static void Main(string[] args)
{
for (; ; )
Console.WriteLine("Hello World");
}
}
}
Output
// will keep printing Infinite times //
Hello world
''''''''''''''''''''''''''''