Junior From PDF Collections C# Collections

What is a Dictionary<TKey, TValue> in C#?

A Dictionary<TKey, TValue> is a generic collection in C# that stores data as

key-value pairs. It provides fast lookup, addition, and removal of values based on their

keys.

  • Keys must be unique
  • Keys must be non-null (for reference types)
  • Values can be null if the type allows it

Example:

Dictionary<string, int> ages = new Dictionary<string, int>();

ges.Add("Alice", 30);

ges.Add("Bob", 25);

Use case: Storing user profiles by ID, or mapping product names to prices.

More from C# Programming Tutorial

All questions for this course
Toolliyo Assistant
Ask about tutorials, ebooks, training, pricing, mentor services, and support. I use public site content only—not admin or internal tools.

care@toolliyo.com

Need callback? Share your details