In C#, Array.FindAll builds a new array that contains every element for which your predicate returns true. Elements that fail the test are skipped.
If nothing matches, you get an empty array (Length 0)—not null. The original array is not modified.
This is a static member of System.Array. You call it with the class name, such as Array.FindAll(...). Arrays in C# have a fixed length after creation; use List<T> when the count must grow.
Syntax
Pass the source array and a predicate. Store the new filtered array.
C#
int[] big = Array.FindAll(nums, x => x >= 10);
Call
What it does
Array.FindAll(nums, x => x >= 10)
All ints at least 10.
Array.FindAll(names, n => n.Contains("a"))
All names containing “a”.
Find returns only the first match. Exists returns only true/false.
Library declarations
C#
public static T[] FindAll<T>(T[] array, Predicate<T> match);
Parameters
Parameter
Description
array
Required. Source array.
match
Required. Predicate deciding which elements to keep.
Return Value
Return Value
Description
T[]
New array of matches. Empty when nothing matches.
C# Examples
Example 1 — Keep Numbers in Range
Collect every int that is at least 10.
C#
using System;
class Program {
static void Main() {
int[] nums = { 3, 10, 7, 25, 12 };
int[] big = Array.FindAll(nums, x => x >= 10);
Console.WriteLine(string.Join(", ", big));
Console.WriteLine("Count: " + big.Length);
}
}
Output
10, 25, 12
Count: 3
How It Works
Filter. Predicate keeps values ≥ 10.
New array.big is separate from nums.
Order kept. Matches appear in the same order as the source.
Source intact. nums still holds five elements.
Example 2 — Empty Array When Nothing Matches
A too-strict predicate yields Length 0.
C#
using System;
class Program {
static void Main() {
string[] names = { "Ann", "Bob" };
string[] hits = Array.FindAll(names, n => n.StartsWith("Z"));
Console.WriteLine("Length: " + hits.Length);
Console.WriteLine("Is empty: " + (hits.Length == 0));
}
}
Output
Length: 0
Is empty: True
How It Works
Not null. You still get a real array object.
Length 0. Safe to loop; the body never runs.
Strict test. No name started with Z.
Different from Find. Find would return null for strings here.
Example 3 — Names Containing a Letter
Keep names that contain the letter a (case-sensitive).
C#
using System;
class Program {
static void Main() {
string[] names = { "Ann", "Bob", "Carla", "Dan" };
string[] hits = Array.FindAll(names, n => n.Contains("a"));
foreach (string n in hits) {
Console.WriteLine(n);
}
}
}
Output
Carla
Dan
How It Works
Contains. Character a must appear as lowercase a.
Ann skipped. “Ann” has A/n only—no lowercase a.
Two hits. Carla and Dan both contain a.
foreach print. One name per line.
Frequently Asked Questions
A new empty T[] with Length 0, not null.
No. It returns a new array of matches.
Find returns the first matching element (or default). FindAll returns every match in a new array.
Yes. Elements keep their relative order from the source.
Yes. Pass a method group that matches Predicate<T>.