| CollectionExtensionsIndexOfT(IEnumerableT, T, IEqualityComparerT) Method |
Searches for the specified object and returns the zero-based index of the first occurrence within all items.
Namespace: TomsToolbox.EssentialsAssembly: TomsToolbox.Essentials (in TomsToolbox.Essentials.dll) Version: 2.21.0+44d18b541fc9419ec3c549350a832394661b2a4d
XMLNS for XAML: Not mapped to an xmlns.
Syntax public static int IndexOf<T>(
this IEnumerable<T> collection,
T item,
IEqualityComparer<T>? comparer
)
<ExtensionAttribute>
Public Shared Function IndexOf(Of T) (
collection As IEnumerable(Of T),
item As T,
comparer As IEqualityComparer(Of T)
) As Integer
Parameters
- collection IEnumerableT
- The collection to search.
- item T
- The object to locate. The value can be null for reference types.
- comparer IEqualityComparerT
- The comparer.
Type Parameters
- T
- The type of elements in the list.
Return Value
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