C# | Get a collection of values in the StringDictionary Last Updated : 11 Jul, 2025 Summarize Comments Improve Suggest changes Share Like Article Like Report StringDictionary.Values property is used to get a collection of values in the StringDictionary. Syntax: public virtual System.Collections.ICollection Values { get; } Return Value: An ICollection that provides the values in the StringDictionary. Example 1: CSHARP // C# code to get a collection // of values in the StringDictionary using System; using System.Collections; using System.Collections.Specialized; class GFG { // Driver code public static void Main() { // Creating a StringDictionary named myDict StringDictionary myDict = new StringDictionary(); // Adding key and value into the StringDictionary myDict.Add("A", "Apple"); myDict.Add("B", "Banana"); myDict.Add("C", "Cat"); myDict.Add("D", "Dog"); // Getting a collection of values // in the StringDictionary foreach(string val in myDict.Values) { Console.WriteLine(val); } } } Output: Dog Banana Cat Apple Example 2: CSHARP // C# code to get a collection // of values in the StringDictionary using System; using System.Collections; using System.Collections.Specialized; class GFG { // Driver code public static void Main() { // Creating a StringDictionary named myDict StringDictionary myDict = new StringDictionary(); // Adding key and value into the StringDictionary myDict.Add("3", "prime & odd"); myDict.Add("2", "prime & even"); myDict.Add("4", "non-prime & even"); myDict.Add("9", "non-prime & odd"); // Getting a collection of values // in the StringDictionary foreach(string val in myDict.Values) { Console.WriteLine(val); } } } Output: prime & even prime & odd non-prime & odd non-prime & even 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 StringDictionary. Therefore, changes to the StringDictionary 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.stringdictionary.values?view=netframework-4.7.2 Comment More infoAdvertise with us Next Article C# | Check if the StringDictionary contains a specific value S Sahil_Bansall Follow Improve Article Tags : C# CSharp-Collections-Namespace CSharp-Specialized-StringDictionary CSharp-Specialized-Namespace Similar Reads C# | Get a collection of keys in the StringDictionary StringDictionary.Keys property is used to get a collection of keys in the StringDictionary. Syntax: public virtual System.Collections.ICollection Keys { get; } Return Value: An ICollection that provides the keys in the StringDictionary. Below given are some examples to understand the implementation 2 min read C# | Get a collection of keys in the StringDictionary StringDictionary.Keys property is used to get a collection of keys in the StringDictionary. Syntax: public virtual System.Collections.ICollection Keys { get; } Return Value: An ICollection that provides the keys in the StringDictionary. Below given are some examples to understand the implementation 2 min read C# | Check if the StringDictionary contains a specific value StringDictionary.ContainsValue(String) method is used to check whether the StringDictionary contains a specific value or not. Syntax: public virtual bool ContainsValue (string value); Here, value is the value to locate in the StringDictionary. The value can be null. Return Value: The method returns 2 min read C# | Check if the StringDictionary contains a specific value StringDictionary.ContainsValue(String) method is used to check whether the StringDictionary contains a specific value or not. Syntax: public virtual bool ContainsValue (string value); Here, value is the value to locate in the StringDictionary. The value can be null. Return Value: The method returns 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 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 Like