# IndexOutOfRangeException

*noun*

say it: **“IN-deks owt uv RAYNJ ek-SEP-shun”** **/ˈɪndɛks aʊt əv reɪndʒ ɪkˈsɛpʃən/**

The error C# throws when code asks an array for a position it does not have.

## What is **IndexOutOfRangeException** in C#?

**IndexOutOfRangeException** — The error C# throws when you ask an array for a position it doesn't have: below 0, or at its `Length` or above. An array of 3 items has indexes 0, 1 and 2, so index 3 is one too far.

```csharp
int[] scores = [21, 14, 35];
Console.WriteLine(scores[2]); // 35
Console.WriteLine(scores[3]); // IndexOutOfRangeException
```

## In a sentence

- “My loop ran one time too many and threw an **IndexOutOfRangeException** on scores\[3\].”

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

Updated: October 28, 2026

Source: https://www.ask-codey.com/glossary/indexoutofrangeexception
