list class : IndexOfByVal(class,int) method

Description

It returns an index of the first child that matches as a value.

Syntax

listIndex.IndexOfByVal(class search, int startPosition)

Arguments

ClassNameDescription
classsearchInstance to search.
intstartPositionStart position of the searching.

Return value

ClassDescription
intIndex.

Sample code

1:

list{string} stringList = new list{string}();

2:

stringList.Add("a");

3:

stringList.Add("b");

4:

stringList.Add("a");

5:

int index = stringList.IndexOfByVal("a", 1); // The result (index) is 2.

Notes

This method searches from the specified position toward the end of the list.

Returns 0 or more if elements that have the same value as the first argument exist in the list, otherwise returns -1.

This method compare equivalence as value. Please note that do not compare equivalence as references.

The first argument of this method has a meaning in int, long, real, string, and bool. Does not have a meaning in other types.

UnknownException (ArgumentOutOfOfRangeException) is thrown if the second argument is less than zero or greater than or equal to the number of elements in the list.

Links for reference

None

Copyright © Rice All rights reserved.