Infinite Loop एक ऐसा Loop है जो कभी Terminate नहीं होता और Indefinitely Repeat होता है।
आइए C# में Infinite Loop Create करने का एक Example देखते हैं।
Example
using System; namespace Demo { class Program { static void Main(string[] args) { for (int a = 0; a < 50; a--) { Console.WriteLine("value: {0}", a); } Console.ReadLine(); } } }ऊपर, Loop तब तक Execute होता है जब तक a < 50. Value Initially 0 Set की जाती है।
int a = 0;
Value of a प्रत्येक Iteration के बाद Decrement होती है क्योंकि यह Set है।
a--;
इसलिए a की Value कभी 50 से ऊपर नहीं होगी और Condition a < 50 हमेशा True रहेगी। यह Loop को Infinite Loop बना देगा।