C# | Check if an array contain the elements that match the specified conditions Last Updated : 11 Jul, 2025 Summarize Comments Improve Suggest changes Share Like Article Like Report Array.Exists(T[], Predicate<T>) Method is used to check whether the specified array contains elements that match the conditions defined by the specified predicate. Syntax: public static bool Exists<T> (T[] array, Predicate<T> match); Parameters: array: It is a one-dimensional, zero-based Array to search. match: It is a Predicate that defines the conditions of the elements to search for. Where T is a type of the elements present in the array. Return Value: The return type of this method is System.Boolean. It return true if array contains one or more elements that match the conditions defined by the specified predicate. Otherwise, return false. Exception: This method will give ArgumentNullException if the value of array is null, or if the value of match is null. Below given are some examples to understand the implementation in a better way: Example 1: CSharp // C# program to illustrate the // Array.Exists(T[], Predicate<T>) Method using System; class GFG { // Main method static public void Main() { // Create and initialize array string[] language = {"Ruby", "C", "C++", "Java", "Perl", "C#", "Python", "PHP"}; // Display language array Console.WriteLine("Display the array:"); foreach(string i in language) { Console.WriteLine(i); } // Display and check the given elements // present in the array or not // Using Exists() method Console.WriteLine("Is Ruby part of language: {0}", Array.Exists(language, element => element == "Ruby")); Console.WriteLine("Is VB part of language: {0}", Array.Exists(language, element => element == "VB")); } } Output:Display the array: Ruby C C++ Java Perl C# Python PHP Is Ruby part of language: True Is VB part of language: False Example 2: CSharp // C# program to illustrate the // Array.Exists(T[], Predicate<T>) Method using System; public class GFG { // Main method static public void Main() { // Create and initialize array string[] ds = {"Array", "Queue", "LinkedList", "Stack", "Graph" }; // Display ds array Console.WriteLine("Given Array: "); foreach(string i in ds) { Console.WriteLine(i); } // Display and check the given elements with the // specified letter is present in the array or not // Using Exists() method Console.WriteLine("Is element start with L letter is present in array: {0}", Array.Exists(ds, element => element.StartsWith("L"))); Console.WriteLine("Is element start with O letter is present in array: {0}", Array.Exists(ds, element => element.StartsWith("O"))); } } Output:Given Array: Array Queue LinkedList Stack Graph Is element start with L letter is present in array: True Is element start with O letter is present in array: False Note: This method is an O(n) operation, where n is the Length of array. Space complexity: O(n) where n is the size of the array Reference: https://learn.microsoft.com/en-us/dotnet/api/system.array.exists?view=netcore-2.1#definition Comment More infoAdvertise with us Next Article C# | Array.BinarySearch(Array, Int32, Int32, Object, IComparer) Method K Kirti_Mangal Follow Improve Article Tags : C# CSharp-method CSharp-Arrays Similar Reads C# | How to get all elements of a List that match the conditions specified by the predicate List<T>.FindAll(Predicate<T>) Method is used to get all the elements that match the conditions defined by the specified predicate. Properties of List: It is different from the arrays. A list can be resized dynamically but arrays cannot.List class can accept null as a valid value for refe 3 min read C# | How to get all elements of a List that match the conditions specified by the predicate List<T>.FindAll(Predicate<T>) Method is used to get all the elements that match the conditions defined by the specified predicate. Properties of List: It is different from the arrays. A list can be resized dynamically but arrays cannot.List class can accept null as a valid value for refe 3 min read C# | Array.BinarySearch(Array, Int32, Int32, Object, IComparer) Method This method searches for an element which is in a one-dimensional sorted array within a range of elements using a specified IComparer interface. Syntax: public static int BinarySearch(Array arr, int index, int length, Object value, IComparer comparer) Parameters: arr : The sorted one-dimensional Arr 4 min read C# | Array.BinarySearch(Array, Int32, Int32, Object, IComparer) Method This method searches for an element which is in a one-dimensional sorted array within a range of elements using a specified IComparer interface. Syntax: public static int BinarySearch(Array arr, int index, int length, Object value, IComparer comparer) Parameters: arr : The sorted one-dimensional Arr 4 min read C# | Array.BinarySearch(Array, Object, IComparer) Method This method searches for a value in a one-dimensional sorted array using a specified IComparer interface. Syntax: public static int BinarySearch(Array arr, Object val, IComparer comparer) Parameters: arr : The one-dimensional sorted array in which the search will happen. val : The object value which 4 min read C# | Array.BinarySearch(Array, Object, IComparer) Method This method searches for a value in a one-dimensional sorted array using a specified IComparer interface. Syntax: public static int BinarySearch(Array arr, Object val, IComparer comparer) Parameters: arr : The one-dimensional sorted array in which the search will happen. val : The object value which 4 min read Like