ערוך

שתף באמצעות


ReadOnlyCollection<T>.IndexOf(T) Method

Definition

Searches for the specified object and returns the zero-based index of the first occurrence within the entire ReadOnlyCollection<T>.

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

Parameters

value
T

The object to locate in the List<T>. The value can be null for reference types.

Returns

The zero-based index of the first occurrence of item within the entire ReadOnlyCollection<T>, if found; otherwise, -1.

Implements

Remarks

The ReadOnlyCollection<T> is searched forward starting at the first element and ending at the last element.

This method determines equality using the default comparer EqualityComparer<T>.Default.

This method performs a linear search; therefore, this method is an O(n) operation, where n is Count.

Applies to

See also