C# Extension Method: Array - FindLast

CSharp · Console

/Program.cs

// C# Extension Method
// Doc: https://csharp-extension.com/en/method/1002637/array-findlast

// @nuget: Z.ExtensionMethods

using System;
using System.Drawing;
					
public class Program
{
    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;
    }
}
;