Mid Collections

How do you check if a Dictionary contains a specific key or value?

  • ContainsKey(key) – checks for key existence
  • ContainsValue(value) – checks for value

Example:

dictionary.ContainsKey("Alice"); // true/false

dictionary.ContainsValue(30); // true/false

More from C# Programming Tutorial

All questions for this course