VOOZH about

URL: https://www.geeksforgeeks.org/c-sharp/c-sharp-dictionary-keys-property/

⇱ C# | Dictionary.Keys Property - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

C# | Dictionary.Keys Property

Last Updated : 11 Jul, 2025
This property is used to get a collection containing the keys in the Dictionary. Syntax:
public System.Collections.Generic.Dictionary<TKey, TValue>.KeyCollection Keys { get; }
Return Value : It returns a collection containing the keys in the Dictionary. Below are the programs to illustrate the use of above-discussed property: Example 1:
Output:
Total key/value pairs in myDict are : 6
Key = Australia
Key = Belgium
Key = Netherlands
Key = China
Key = Russia
Key = India
Example 2:
Output:
Total key/value pairs in myDict are : 4
Key = 9
Key = 3
Key = 4
Key = 1
Reference:
Comment

Explore