C# Array FindLast() Method

Beginner
5 min read
Updated: Nov 2026
3 examples
Array

Definition

In C#, Array.FindLast walks from the end of the array and returns the last element that makes your predicate true.

If nothing matches, you get default(T) (null for reference types, 0 for int). For the index instead of the value, use FindLastIndex.

This is a static member of System.Array. You call it with the class name, such as Array.FindLast(...). Arrays in C# have a fixed length after creation; use List<T> when the count must grow.

Syntax

Pass the array and predicate. Handle the default carefully.

C#
int hit = Array.FindLast(nums, x => x > 10);
CallWhat it does
Array.FindLast(nums, x => x > 10)Last int greater than 10, or 0 if none.

Find returns the first match; FindLast returns the last match.

Library declarations
C#
public static T FindLast<T>(T[] array, Predicate<T> match);

Parameters

ParameterDescription
arrayRequired. Array to search.
matchRequired. Predicate for a match.

Return Value

Return ValueDescription
TLast matching element, or default(T).

C# Examples

Example 1 — Last Matching Number

Find the last int greater than 10.

C#
using System;

class Program {
    static void Main() {
        int[] nums = { 4, 25, 8, 30, 2 };
        int hit = Array.FindLast(nums, x => x > 10);
        Console.WriteLine(hit);
    }
}

How It Works

  1. From the end. Scanning starts at 2, then 30.
  2. 30 matches. It is the last value > 10.
  3. 25 skipped as “last”. An earlier match is not returned.
  4. Element, not index. The method returns 30 itself.

Example 2 — Default When Missing

Show null for a failed string search.

C#
using System;

class Program {
    static void Main() {
        string[] names = { "Ann", "Bob" };
        string hit = Array.FindLast(names, n => n.Length > 5);
        Console.WriteLine(hit == null ? "(none)" : hit);
    }
}

How It Works

  1. Both short. Ann and Bob have length 3.
  2. Null default. Reference types return null.
  3. Null-coalesce print. Avoid printing a blank null line.
  4. Same idea as Find. Only the search direction differs.

Example 3 — Last Among Several Matches

Multiple even numbers; FindLast picks the rightmost.

C#
using System;

class Program {
    static void Main() {
        int[] nums = { 2, 3, 4, 5, 6 };
        int hit = Array.FindLast(nums, x => x % 2 == 0);
        Console.WriteLine(hit);
        Console.WriteLine("Find would return " + Array.Find(nums, x => x % 2 == 0));
    }
}

How It Works

  1. Several evens. 2, 4, and 6 all match.
  2. FindLast → 6. Rightmost even wins.
  3. Find → 2. Leftmost even for contrast.
  4. Choose intentionally. First vs last depends on your rule.

Frequently Asked Questions

default(T), such as null for strings or 0 for ints.
Find returns the first match; FindLast returns the last match.
Use FindLastIndex.
No. It only reads elements.
Yes. x => x > 10 is the usual style.

Next: FindLastIndex()

Return the index of the last predicate match, or -1 with System.Array.

FindLastIndex() 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.

13 people found this page helpful