C# | Check if an array contain the elements that match the specified conditions
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.
public static bool Exists<T> (T array, Predicate<T> match);
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:
Display the array: Ruby C C++ Java Perl C# Python PHP Is Ruby part of language: True Is VB part of language: False
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.