Infinite Loop

noun

say it: “IN-fih-nit loop” /ˈɪnfɪnɪt luːp/

A loop that never stops, because its condition never becomes false.

What is Infinite Loop in C#?

Infinite Loop — A loop whose stopping condition never becomes false.

class NumberFinder
{
    int FirstOdd(int[] numbers)
    {
        foreach (int number in numbers)
        {
            if (number % 2 == 0)
            {
                continue;
            }

            return number;
        }

        return -1;
    }
}

In a sentence

  • “I forgot count++, so it became an infinite loop and I had to press Ctrl+C.”

Level: Apprentice · More C# terms at this level

Updated

In other subjects