Array - Exists

Determines whether the specified array contains elements that match the conditions defined by the specified predicate.

Try it

public static void Main(string[] args)
    string[] planets = { "Mercury", "Venus",
        "Earth", "Mars", "Jupiter",
        "Saturn", "Uranus", "Neptune" };

    // C# Extension Method: Array - Exists
    Console.WriteLine("Planets begin with 'M': {0}", planets.Exists(element => element.StartsWith("M")));
    Console.WriteLine("One or more planets begin with 'T': {0}", planets.Exists(element => element.StartsWith("T")));
    Console.WriteLine("Is Pluto one of the planets? {0}", planets.Exists(element => element == "Pluto"));

View Source
using System;

public static partial class Extensions
    /// <summary>
    ///     A T[] extension method that exists.
    /// </summary>
    /// <typeparam name="T">Generic type parameter.</typeparam>
    /// <param name="array">The array to act on.</param>
    /// <param name="match">Specifies the match.</param>
    /// <returns>true if it succeeds, false if it fails.</returns>
    public static Boolean Exists<T>(this T[] array, Predicate<T> match)
        return Array.Exists(array, match);