SortedList.IndexOfValue(Object) Method is used to get the zero-based index of the first occurrence of the specified value in a SortedList object.
public virtual int IndexOfValue (object value);
Here, value is the Value which is to be located in the SortedList object. The value can be null.
Return Value: This method return the zero-based index of the first occurrence of the value parameter, if the value is found in the SortedList object otherwise it returns -1.
Below programs illustrate the use of above-discussed method:
Index Keys Values  Fifth Manish  First Ram  Fourth Rohit  Second Shyam  Third Mohit The index of value 'Rohit' is: 2 The index of value 'Kirti' is: -1
Index Keys Values  1 C++  2 Java  3 DSA  4  5 C# The index of value 'null' is: 3
- The index sequence is based on the sort sequence. When an element is added, it is inserted into SortedList in the correct sort order, and the indexing adjusts accordingly. When an element is removed, the indexing also adjusts accordingly. So, the index of a specific key/value pair may change.
- The values of the elements of the SortedList are compared to the specified value using the Equals method.
- This method uses a linear search; therefore, this method is an O(n) operation, where n is Count.
- C# | Getting the value at the specified index of a SortedList object
- C# | Getting the index of the specified key in a SortedList object
- C# | Getting the key at the specified index of a SortedList object
- C# | Replacing the value at a specific index in a SortedList object
- C# | Remove from the specified index of a SortedList
- C# | Getting the keys in a SortedList object
- C# | Getting the Values in a SortedList object
- C# | Search in a SortedList object
- C# | Getting the list of Values of a SortedList object
- C# | Check if a SortedList object contains a specific value
- C# | Getting the list of keys of a SortedList object
- C# | Check whether a SortedList object contains a specific key
- C# | Check if a SortedList object is synchronized
- C# | Copying the SortedList elements to an Array Object
- C# | Check if a SortedList object has a fixed size
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.