METHOD
List<T>.FindIndex
Returns the index of the first matching element, or -1 when no element matches. Unlike a returned default value, -1 explicitly signals absence.
Formal Syntax & Structure
csharp syntaxcsharp
items.FindIndex(predicate)Working Example
Example Snippetcsharp
using System;using System.Collections.Generic;var items = new List<int> { 3, 9, 8 };Console.WriteLine(items.FindIndex(x => x > 5)); // 1