IndexOfValue(Value: Variant): Integer;
Value. Value of the element, which index should be obtained.
The IndexOfValue method returns element index by value.
The method return -1 if the element with the specified value is missing.
Sub UserProc;
Var
SortList: ISortedList;
i: Integer;
Begin
SortList := New SortedList.Create;
For i := 0 To Math.RandBetweenI(50, 100) Do
SortList.Add("Key_" + Math.RandBetweenI(0, 100).ToString, "Number " + Math.RandBetweenI(0, 100).ToString);
End For;
i := SortList.IndexOfValue("Number 25");
End Sub UserProc;
After executing the example the "i" variable contains element index with the Number 25 value if it is exists.
See also: