How to create an infinite loop in C#?

An infinite loop is a loop that never terminates and repeats indefinitely.

Let us see an example to create an infinite loop in C#.

Example

using System;
namespace Demo {
   class Program {
      static void Main(string[] args) {
         for (int a = 0; a 

Above, the loop executes until a

int a = 0;

The value of a decrements after each iteration since it is set to.

a--;

Therefore the value of a will never be above 50 and the condition a

Updated on: 2020-06-23T12:10:34+05:30

1K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements