ImmutableList<T>.IndexOf 方法

定义

重载

IndexOf(T)

搜索指定的对象,并返回整个不可变列表中第一个匹配项的从零开始的索引。

IndexOf(T, Int32, Int32, IEqualityComparer<T>)

搜索指定对象并返回列表中从指定索引开始并包含指定元素数的这部分元素中第一个匹配项的从零开始的索引。

IndexOf(T)

Source:
ImmutableList_1.cs
Source:
ImmutableList_1.cs
Source:
ImmutableList_1.cs

搜索指定的对象,并返回整个不可变列表中第一个匹配项的从零开始的索引。

public:
 virtual int IndexOf(T value);
public int IndexOf (T value);
abstract member IndexOf : 'T -> int
override this.IndexOf : 'T -> int
Public Function IndexOf (value As T) As Integer

参数

value
T

要在不可变列表中查找的对象。 对于引用类型,该值可以为 null

返回

如果找到,则为整个不可变列表中 value 第一个匹配项的从零开始的索引;否则为 ?1。

实现

适用于

IndexOf(T, Int32, Int32, IEqualityComparer<T>)

Source:
ImmutableList_1.cs
Source:
ImmutableList_1.cs
Source:
ImmutableList_1.cs

搜索指定对象并返回列表中从指定索引开始并包含指定元素数的这部分元素中第一个匹配项的从零开始的索引。

public:
 virtual int IndexOf(T item, int index, int count, System::Collections::Generic::IEqualityComparer<T> ^ equalityComparer);
public int IndexOf (T item, int index, int count, System.Collections.Generic.IEqualityComparer<T> equalityComparer);
public int IndexOf (T item, int index, int count, System.Collections.Generic.IEqualityComparer<T>? equalityComparer);
abstract member IndexOf : 'T * int * int * System.Collections.Generic.IEqualityComparer<'T> -> int
override this.IndexOf : 'T * int * int * System.Collections.Generic.IEqualityComparer<'T> -> int
Public Function IndexOf (item As T, index As Integer, count As Integer, equalityComparer As IEqualityComparer(Of T)) As Integer

参数

item
T

要在列表中找到的对象。对于引用类型,该值可以为 null。

index
Int32

从零开始的搜索的起始索引。 空列表中 0(零)为有效值。

count
Int32

要搜索的部分中的元素数。

equalityComparer
IEqualityComparer<T>

要在搜索中使用的相等性比较器。

返回

如果在列表中从 index 开始并包含 count 个元素的元素范围内找到 item 的第一个匹配项,则为该项的从零开始的索引;否则为 -1。

实现

适用于