In C#, Array.Exists answers a yes/no question: does any element pass this test? It returns true or false.
Use Exists when you do not need the element or index—only whether a match is present. Under the hood it stops at the first success.
This is a static member of System.Array. You call it with the class name, such as Array.Exists(...). Arrays in C# have a fixed length after creation; use List<T> when the count must grow.
Syntax
Pass the array and predicate; use the bool directly in an if.
C#
bool ok = Array.Exists(nums, x => x < 0);
Call
What it does
Array.Exists(nums, x => x < 0)
True if any negative int exists.
Array.Exists(names, n => n == "Bob")
True if Bob is present.
TrueForAll asks whether every element matches. Find returns the element itself.
Library declarations
C#
public static bool Exists<T>(T[] array, Predicate<T> match);
Parameters
Parameter
Description
array
Required. Array to test.
match
Required. Predicate for a matching element.
Return Value
Return Value
Description
true
At least one element matched.
false
No element matched.
C# Examples
Example 1 — Any Negative Number?
Check whether the array contains a value below zero.
C#
using System;
class Program {
static void Main() {
int[] nums = { 3, -1, 8 };
bool hasNeg = Array.Exists(nums, x => x < 0);
Console.WriteLine(hasNeg);
}
}
Output
True
How It Works
Predicate.x < 0 is the test.
Hit at -1. Exists can stop immediately.
Bool result. True means “yes, something matched.”
No index. Call FindIndex if you need where.
Example 2 — False When None Match
All positive numbers → Exists is false.
C#
using System;
class Program {
static void Main() {
int[] nums = { 1, 2, 3 };
Console.WriteLine(Array.Exists(nums, x => x < 0));
}
}
Output
False
How It Works
Full scan. Every element was tested.
All fail. Result is false.
Clean if.if (Array.Exists(...)) reads well.
Empty array. Exists on Length 0 is also false.
Example 3 — Any Name Starting With C
Combine Exists with string methods inside the lambda.
C#
using System;
class Program {
static void Main() {
string[] names = { "Ann", "Bob", "Cara" };
bool ok = Array.Exists(names, n => n.StartsWith("C"));
Console.WriteLine(ok);
}
}
Output
True
How It Works
StartsWith. Cara matches.
Short-circuit. No need to check further after Cara.
Readable intent. “Does any name start with C?”
Case sensitive. Default StartsWith cares about case.
Frequently Asked Questions
true if any element matches the predicate; otherwise false.
Exists returns a bool. Find returns the element or default.
Exists asks “any?”. TrueForAll asks “all?”.
Yes. It can return true as soon as one element matches.