VOOZH about

URL: https://www.geeksforgeeks.org/c-sharp/c-sharp-gets-an-icollection-containing-the-keys-in-the-hashtable/

⇱ C# | Gets an ICollection containing the keys in the Hashtable - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

C# | Gets an ICollection containing the keys in the Hashtable

Last Updated : 11 Jul, 2025
Hashtable.Keys Property is used to get an ICollection containing the keys in the Hashtable. Syntax:
public virtual System.Collections.ICollection Keys { get; }
Return Value: This property returns an ICollection containing the keys in the Hashtable. Note:
  • The order of keys in the ICollection is unspecified.
  • Retrieving the value of this property is an O(1) operation.
Below programs illustrate the use of above-discussed property: Example 1:
Output:
5: Odd and Prime
9: Odd
2: Even and Prime
4: Even
Example 2:
Output:
Chandigarh: City
India: Country
China: Country
Mars: Planet
Reference:
Comment

Explore