# foreach Loop

*noun*

say it: **“for-EECH loop”** **/fɔːrˈiːtʃ luːp/**

A C# loop that visits every item in a collection, one at a time, without an index.

## What is **foreach Loop** in C#?

**foreach Loop** — A loop that visits each item in a collection or sequence.

```csharp
class PetRegistry
{
    int CountNames(string[] pets)
    {
        int count = 0;

        foreach (string pet in pets)
        {
            count++;
        }

        return count;
    }
}
```

## In a sentence

- “A **foreach loop** prints every title in the reading list.”

Level: Apprentice · [More C# terms at this level](https://www.ask-codey.com/glossary?category=c-sharp&level=2)

Updated: November 9, 2026

## In other subjects

- [foreach Loop in PowerShell](https://www.ask-codey.com/glossary/foreach-loop-powershell)

Source: https://www.ask-codey.com/glossary/foreach-loop
