C# | Get an ICollection containing the values in HybridDictionary Last Updated : 11 Jul, 2025 Comments Improve Suggest changes Like Article Like Report HybridDictionary.Values property is used to get an ICollection containing the values in the HybridDictionary. Syntax: public System.Collections.ICollection Values { get; } Return Value: It returns an ICollection containing the values in the HybridDictionary. Below programs illustrate the use of HybridDictionary.Values property: Example 1: CSHARP // C# code to get an ICollection containing // the values in the HybridDictionary. using System; using System.Collections; using System.Collections.Specialized; class GFG { // Driver code public static void Main() { // Creating a HybridDictionary named myDict HybridDictionary myDict = new HybridDictionary(); // Adding key/value pairs in myDict myDict.Add("A", "Apple"); myDict.Add("B", "Banana"); myDict.Add("C", "Cat"); myDict.Add("D", "Dog"); myDict.Add("E", "Elephant"); myDict.Add("F", "Fish"); // Creating a String arr named myArr String[] myArr = new String[myDict.Count]; // copying the Values in HybridDictionary // to a one-dimensional Array instance // at the specified index. myDict.Values.CopyTo(myArr, 0); // To get an ICollection containing // the Values in the HybridDictionary for (int i = 0; i < myDict.Count; i++) Console.WriteLine(myArr[i]); } } Output: Apple Banana Cat Dog Elephant Fish Example 2: CSHARP // C# code to get an ICollection containing // the values in the HybridDictionary. using System; using System.Collections; using System.Collections.Specialized; class GFG { // Driver code public static void Main() { // Creating a HybridDictionary named myDict HybridDictionary myDict = new HybridDictionary(); // Adding key/value pairs in myDict myDict.Add("I", "first"); myDict.Add("II", "second"); myDict.Add("III", "third"); myDict.Add("IV", "fourth"); myDict.Add("V", "fifth"); // Creating a String arr named myArr String[] myArr = new String[myDict.Count]; // copying the Values in HybridDictionary // to a one-dimensional Array instance // at the specified index. myDict.Values.CopyTo(myArr, 0); // To get an ICollection containing // the Values in the HybridDictionary for (int i = 0; i < myDict.Count; i++) Console.WriteLine(myArr[i]); } } Output: first second third fourth fifth Note: The order of the values in the ICollection is unspecified, but it is the same order as the associated keys in the ICollection returned by the Keys method. The returned ICollection is not a static copy. Instead, the ICollection refers back to the values in the original HybridDictionary. Therefore, changes to the HybridDictionary continue to be reflected in the ICollection. Retrieving the value of this property is an O(1) operation. Reference: https://learn.microsoft.com/en-us/dotnet/api/system.collections.specialized.hybriddictionary.values?view=netframework-4.7.2 Comment More infoAdvertise with us Next Article C# | Gets an ICollection containing the keys in the Hashtable S Sahil_Bansall Follow Improve Article Tags : C# CSharp-Specialized-Namespace CSharp-Specialized-HybridDictionary Similar Reads C# | Get an ICollection containing the keys in HybridDictionary HybridDictionary.Keys property is used to get an ICollection containing the keys in the HybridDictionary. Syntax: public System.Collections.ICollection Keys { get; } Return Value: It returns an ICollection containing the keys in the HybridDictionary. Below programs illustrate the use of HybridDictio 2 min read C# | Gets an ICollection containing the values in the Hashtable Hashtable.Values Property is used to get an ICollection containing the values in the Hashtable. Syntax: public virtual System.Collections.ICollection Values { get; } Return Value: This property returns an ICollection containing the values in the Hashtable. Note: The order of values in the ICollectio 2 min read C# | Get an ICollection containing the values in ListDictionary ListDictionary.Values property is used to get an ICollection containing the values in the ListDictionary. Syntax: public System.Collections.ICollection Values { get; } Return Value : It returns an ICollection containing the values in the ListDictionary. Below are the programs to illustrate the use o 2 min read C# | Gets an ICollection containing the keys in the Hashtable 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 unspe 2 min read C# | Get an ICollection containing values in OrderedDictionary OrderedDictionary.Values property is used to get an ICollection object containing the values in the OrderedDictionary collection. Syntax: public System.Collections.ICollection Values { get; } Return Value: It returns an ICollection object containing the values in the OrderedDictionary collection. Be 2 min read C# | Adding the specified key and value into HybridDictionary HybridDictionary.Add(Object, Object) method is used to add an entry with the specified key and value into the HybridDictionary. Syntax: public void Add (object key, object value); Parameters: key : The key of the entry to add. value : The value of the entry to add. The value can be null. Exceptions: 3 min read Like