Array - FindLast

A T[] extension method that searches for the first last.

Try it

public static void Main()
{
    Point[] points = { new Point(100, 200),
    new Point(150, 250), new Point(250, 375),
    new Point(275, 395), new Point(295, 450),
	new Point(405, 425), new Point(375, 850) };

    // C# Extension Method: Array - FindLast
    Point first = points.FindLast(ProductGT10);

    Console.WriteLine("Found: X = {0}, Y = {1}", first.X, first.Y);
}

// Return true if X times Y is greater than 100000.
private static bool ProductGT10(Point p)
{
    return p.X * p.Y > 100000;
}

View Source
using System;

public static partial class Extensions
{
    /// <summary>
    ///     A T[] extension method that searches for the first last.
    /// </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>The found last.</returns>
    public static T FindLast<T>(this T[] array, Predicate<T> match)
    {
        return Array.FindLast(array, match);
    }
}