System::Array::IndexOf 方法

Array::IndexOf(const T&) const method

确定数组中指定项首次出现的索引。

virtual int System::Array<T>::IndexOf(const T &item) const override
参数类型描述
const T&要确定的项索引

ReturnValue

如果找到该项,则返回指定项首次出现的索引;否则返回 -1

另见

Array::IndexOf(const ArrayPtr<ArrayType>&, const ValueType&) method

确定数组中指定项首次出现的索引。

template<typename ArrayType,typename ValueType> static int System::Array<T>::IndexOf(const ArrayPtr<ArrayType> &arr, const ValueType &value)
参数描述
ArrayType目标数组中元素的类型
ValueType要在数组中搜索的项的类型
参数类型描述
arrconst ArrayPtr<ArrayType>&Array 用于搜索指定的项
const ValueType&要确定的项索引

ReturnValue

如果找到该项,则返回指定项首次出现的索引;否则返回 -1

另见

Array::IndexOf(const ArrayPtr<ArrayType>&, const ValueType&, int) method

确定数组中指定项首次出现的索引,搜索起始于指定的索引。

template<typename ArrayType,typename ValueType> static int System::Array<T>::IndexOf(const ArrayPtr<ArrayType> &arr, const ValueType &value, int startIndex)
参数描述
ArrayType目标数组中元素的类型
ValueType要在数组中搜索的项的类型
参数类型描述
arrconst ArrayPtr<ArrayType>&Array 用于搜索指定的项
const ValueType&要确定的项索引
startIndexint搜索开始的索引

ReturnValue

如果找到该项,则返回指定项首次出现的索引;否则返回 -1

另见

Array::IndexOf(const ArrayPtr<ArrayType>&, const ValueType&, int, int) method

确定在由起始索引和范围内元素数量指定的数组项范围中,指定项首次出现的索引。

template<typename ArrayType,typename ValueType> static int System::Array<T>::IndexOf(const ArrayPtr<ArrayType> &arr, const ValueType &value, int startIndex, int count)
参数描述
ArrayType目标数组中元素的类型
ValueType要在数组中搜索的项的类型
参数类型描述
arrconst ArrayPtr<ArrayType>&Array 用于搜索指定的项
const ValueType&要确定的项索引
startIndexint搜索开始的索引
countint要搜索的范围内的元素数量

ReturnValue

如果找到该项,则返回指定项首次出现的索引;否则返回 -1

另见