[This is preliminary documentation and is subject to change.]

Gets index of first occurence of given item in given collection

Namespace: Tools.LinqT
Assembly: Tools (in Tools.dll) Version: 1.5.3.38916 (1.5.3.38916)

Syntax

C#
public static int IndexOf<T>(
	this IEnumerable<T> collection,
	T item
)
Visual Basic
<ExtensionAttribute> _
Public Shared Function IndexOf(Of T) ( _
	collection As IEnumerable(Of T), _
	item As T _
) As Integer
Visual C++
[ExtensionAttribute]
public:
generic<typename T>
static int IndexOf(
	IEnumerable<T>^ collection, 
	T item
)
F#
static member IndexOf : 
        collection:IEnumerable<'T> * 
        item:'T -> int 
JScript
JScript does not support generic types or methods.

Parameters

collection
Type: System.Collections.Generic..::..IEnumerable<(Of <(<'T>)>)>
Collection to find item in
item
Type: T
Item to be found

Type Parameters

T
Type of items in collection

Return Value

Index of first occurence of item in collection (compared using Equals(Object)). -1 if item is not found in collection.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type IEnumerable<(Of <(<'T>)>)>. When you use instance method syntax to call this method, omit the first parameter. For more information, see or .

Exceptions

ExceptionCondition
System..::..ArgumentNullExceptioncollection is null.

See Also

Collapse/expand Version History

1.5.3

  • This function is new in version 1.5.3