public bool ContainsValue(object value);
SortedList sl = new SortedList(); sl.Add(1, "one"); sl.Add(2, "two"); sl.Add(3, "three"); bool res = sl.ContainsValue("two"); Console.WriteLine(res); // Output: True
SortedList sl = new SortedList(); sl.Add("apple", 10); sl.Add("banana", 20); sl.Add("orange", 30); bool res = sl.ContainsValue("grapes"); Console.WriteLine(res); // Output: FalseIn this example, we create a SortedList object sl and add three key-value pairs where the keys are strings and values are integers. Then, we use the ContainsValue method to check whether the value "grapes" is present in it or not. Since it is not present, the method returns False. In conclusion, the ContainsValue method of SortedList class is used to check whether a given value is present in the collection or not. This method belongs to the System.Collections package library of C#.