# Key-Value Pair

*noun*

say it: **“KEE VAL-yoo pair”** **/kiː ˈvæljuː pɛr/**

One entry in a dictionary: a key to look it up by and the value stored under that key.

## What is **Key-Value Pair** in C#?

**Key-Value Pair** — One entry in a dictionary: a key you look things up by, and the value stored under it. Looping over a `Dictionary` gives you one `KeyValuePair` at a time, with `.Key` and `.Value`.

```csharp
Dictionary<string, int> stock = new() { ["Dune"] = 4, ["Emma"] = 2 };
foreach (KeyValuePair<string, int> pair in stock)
{
    Console.WriteLine($"{pair.Key}: {pair.Value}");
}
// Dune: 4
// Emma: 2
```

## In a sentence

- “Each **key-value pair** in the stock dictionary holds a title and how many copies we have.”

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

Updated: October 28, 2026

## In other subjects

- [Key-Value Pair in JavaScript](https://www.ask-codey.com/glossary/key-value-pair-javascript)

Source: https://www.ask-codey.com/glossary/key-value-pair-c-sharp
