C# List FindIndex() Method

Beginner
5 min read
Updated: Nov 2026
3 examples
List

Definition

In C#, List.FindIndex(match) tells you where the first item that passes a test is. It scans from the start and returns that item's index, or -1 when no item passes.

It is the "rule" version of IndexOf(). IndexOf compares with one value, while FindIndex takes a lambda such as n => n > 10. Unlike Find(), its "not found" answer, -1, can never be confused with a real item.

This is an instance member of List<T> (System.Collections.Generic). Call it on a list variable, such as numbers.FindIndex(...). A List<T> is a class, so two variables can share one list. It keeps items in the order you put them, allows duplicates, and grows when needed. An array, by comparison, has a fixed length.

Syntax

Pass a lambda. Optional overloads add a start index, and a count of items to search.

C#
List<int> numbers = new List<int> { 4, 15, 22, 9, 30 };
int a = numbers.FindIndex(n => n > 10);        // 1
int b = numbers.FindIndex(2, n => n > 10);     // 2: start at index 2
int c = numbers.FindIndex(n => n > 100);       // -1
CallWhat it does
numbers.FindIndex(n => n > 10)Index of the first number above 10, or -1.
numbers.FindIndex(2, n => n > 10)Starts the scan at index 2.
numbers.FindIndex(2, 3, n => n > 10)Looks at 3 items only, beginning at index 2.

A start index above Count (or a negative one) throws ArgumentOutOfRangeException. The index you get back is always a position in the whole list, even when you searched only a part. See FindLastIndex() to search from the end.

Library declarations
C#
public int FindIndex(Predicate<T> match);
public int FindIndex(int startIndex, Predicate<T> match);
public int FindIndex(int startIndex, int count, Predicate<T> match);

Parameters

ParameterDescription
matchRequired. A Predicate<T>: a lambda or method that returns true for the item you want.
startIndexOptional overload. The zero-based index where the search begins.
countOptional overload. The number of items to search, starting at startIndex.

Return Value

Return ValueDescription
int (0 or more)The zero-based index of the first item that passed the test.
-1No item passed the test.

C# Examples

Example 1 — Find the Position of a Match

Ask where the first big number is, and handle the case where there is none.

C#
using System;
using System.Collections.Generic;

class Program {
    static void Main() {
        List<int> numbers = new List<int> { 4, 15, 22, 9, 30 };

        int ix = numbers.FindIndex(n => n > 10);
        Console.WriteLine(ix);

        int missing = numbers.FindIndex(n => n > 100);
        Console.WriteLine(missing == -1 ? "no match" : "at " + missing);
    }
}

How It Works

  1. Rule, not value. The lambda n => n > 10 is tested on each item. 4 fails, 15 passes.
  2. Position returned. 15 is at index 1, so that is the answer. Items 22 and 30 are never needed.
  3. -1 is the signal. Nothing is above 100, so the result is -1.
  4. Safe handling. The program compares with -1 before using the number, and prints a friendly message instead of crashing.

Example 2 — Search from a Start Index

Skip the early items by starting the search later. Combine it with a count to limit the end too.

C#
using System;
using System.Collections.Generic;

class Program {
    static void Main() {
        List<int> numbers = new List<int> { 4, 15, 22, 9, 30 };

        Console.WriteLine(numbers.FindIndex(2, n => n > 10));
        Console.WriteLine(numbers.FindIndex(3, n => n > 10));
        Console.WriteLine(numbers.FindIndex(0, 3, n => n > 25));
    }
}

How It Works

  1. Begin at index 2. The first item looked at is 22, which passes, so the answer is 2. Index 1 (15) is skipped.
  2. Begin at index 3. 9 fails and 30 passes, so the answer is 4.
  3. Count limits the range. (0, 3, ...) checks only indexes 0, 1, and 2. The 30 at index 4 is outside, so the result is -1.
  4. Whole-list numbers. The returned index is relative to the start of the list, not to the start index, which makes it safe to use directly.

Example 3 — Find a Position, Then Replace the Item

Use the index to replace one item with the indexer. Only replace when the search succeeded.

C#
using System;
using System.Collections.Generic;

class Program {
    static void Main() {
        List<string> names = new List<string> { "Asha", "Ben", "Bella", "Chen" };

        int ix = names.FindIndex(s => s.StartsWith("B"));
        if (ix >= 0) {
            names[ix] = "Bruno";
        }

        Console.WriteLine(string.Join(", ", names));
        Console.WriteLine(ix);
    }
}

How It Works

  1. Rule on text. s.StartsWith("B") matches both "Ben" and "Bella". The search stops at the first one, index 1.
  2. Guard. ix >= 0 means a match was found. Without this check, a missing match would try to write to index -1.
  3. Replace, not insert. names[ix] = "Bruno" overwrites the item at that index. The list keeps the same length.
  4. Only the first. "Bella" also starts with B, but it stays untouched, because FindIndex reports a single position.

Frequently Asked Questions

The zero-based index of the first item that passes your test lambda, or -1 if no item passes.
IndexOf looks for one specific value by equality. FindIndex takes a predicate, so it can search with any rule.
Find returns default(T) when nothing matches, which can look like a real value (0 or null). FindIndex returns -1, which is never a valid index.
No. It is always a position in the whole list, even when you give a start index or a count.
Use FindLastIndex, which scans backward from the end of the list.

Next: FindLast()

Return the last item that passes a test, or the default value (0 or null) if none does.

FindLast() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

10 people found this page helpful