Infinite Loop in c#

Sometimes we need to write the infinite the loop in our program. The terimination may happens upon some decision made in the statement block.

For example when we write the console application, we may have some menu structure and it will keep on display to allow the users choose any one option.


1. Employee Creation
2. Employee List
3. Search
4. Exit

The above list will be displayed the users to select any one option to perform the operation. Then we need some looping mechanism to display infinitely.

The C# allows to write the infinite the loop. It can be done in the for and while loop statement.

for(;;)
{
  //Statement
}

while(true)
{

 //Statement

}


The above statement allows to run infinitely in the C# programming.


Next Recommended Reading Exploring C# 12 Features