C# | Get an ICollection containing values in OrderedDictionary Last Updated : 01 Feb, 2019 Comments Improve Suggest changes Like Article Like Report 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. Below given are some examples to understand the implementation in a better way: Example 1: CSHARP // C# code to get an ICollection // containing the values in OrderedDictionary using System; using System.Collections; using System.Collections.Specialized; class GFG { // Driver method public static void Main() { // Creating a orderedDictionary named myDict OrderedDictionary myDict = new OrderedDictionary(); // Adding key and value in myDict myDict.Add("key1", "value1"); myDict.Add("key2", "value2"); myDict.Add("key3", "value3"); myDict.Add("key4", "value4"); myDict.Add("key5", "value5"); // Getting an ICollection containing // the values in OrderedDictionary ICollection valueCollection = myDict.Values; // Creating a String array String[] myValues = new String[myDict.Count]; // Copying the OrderedDictionary elements to // a one-dimensional Array object at the // specified index. valueCollection.CopyTo(myValues, 0); for (int i = 0; i < myDict.Count; i++) { Console.WriteLine(myValues[i]); } } } Output: value1 value2 value3 value4 value5 Example 2: CSHARP // C# code to get an ICollection // containing the values in OrderedDictionary using System; using System.Collections; using System.Collections.Specialized; class GFG { // Driver method public static void Main() { // Creating a orderedDictionary named myDict OrderedDictionary myDict = new OrderedDictionary(); // Adding key and value in myDict myDict.Add("A", "Apple"); myDict.Add("B", "Banana"); myDict.Add("C", "Cat"); myDict.Add("D", "Dog"); // Getting an ICollection containing // the values in OrderedDictionary ICollection valueCollection = myDict.Values; // Creating a String array String[] myValues = new String[myDict.Count]; // Copying the OrderedDictionary elements to // a one-dimensional Array object at the // specified index. valueCollection.CopyTo(myValues, 0); for (int i = 0; i < myDict.Count; i++) { Console.WriteLine(myValues[i]); } } } Output: Apple Banana Cat Dog Reference: https://docs.microsoft.com/en-us/dotnet/api/system.collections.specialized.ordereddictionary.values?view=netframework-4.7.2 Comment More infoAdvertise with us Next Article C# | Get an ICollection containing values in OrderedDictionary S Sahil_Bansall Follow Improve Article Tags : C# CSharp-Specialized-Namespace CSharp-Specialized-OrderedDictionary Similar Reads C# | Get an ICollection containing keys in OrderedDictionary OrderedDictionary.Keys property is used to get an ICollection object containing the keys in the OrderedDictionary collection. Syntax: public System.Collections.ICollection Keys { get; } Return Value: It returns an ICollection object containing the keys in the OrderedDictionary collection. Below give 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# | Get an ICollection containing the keys in ListDictionary ListDictionary.Keys property is used to get an ICollection containing the keys in the ListDictionary. Syntax: public System.Collections.ICollection Keys { get; } Return Value : It returns an ICollection containing the keys in the ListDictionary. Below are the programs to illustrate the use of ListDi 2 min read C# | Add key and value into OrderedDictionary collection OrderedDictionary.Add(Object, Object) method is used to add an entry with the specified key and value into the OrderedDictionary collection with the lowest available index. Syntax: public void Add (object key, object value); Parameters: key : The key of the entry to add. value : The value of the ent 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 Like