| CollectionExtensionsIndexOfT Method (IEnumerableT, T) |
Searches for the specified object and returns the zero-based index of the first occurrence within all items.
Namespace:
TomsToolbox.Essentials
Assembly:
TomsToolbox.Essentials (in TomsToolbox.Essentials.dll)
Syntax public static int IndexOf<T>(
this IEnumerable<T> collection,
T item
)
<ExtensionAttribute>
Public Shared Function IndexOf(Of T) (
collection As IEnumerable(Of T),
item As T
) As Integer
Parameters
- collection
- Type: System.Collections.GenericIEnumerableT
The collection to search. - item
- Type: T
The object to locate. The value can be null for reference types.
Type Parameters
- T
- The type of elements in the list.
Return Value
Type:
Int32
The zero-based index of the first occurrence of
item, if found; otherwise, –1.
Usage Note
In Visual Basic and C#, you can call this method as an instance method on any object of type
IEnumerableT. When you use instance method syntax to call this method, omit the first parameter. For more information, see
Extension Methods (Visual Basic) or
Extension Methods (C# Programming Guide).
See Also