Search array by the specified predicate, and returns the first occurrence within the entire Array in CSharp

Description

The following code shows how to search array by the specified predicate, and returns the first occurrence within the entire Array.

Example


/* w w w. j a va 2 s.com*/
using System;
using System.Drawing;

public class Example
{
    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) };

        Point first = Array.Find(points, ProductGT10);

    }
    private static bool ProductGT10(Point p)
    {
        if (p.X * p.Y > 100000)
        {
            return true;
        }
        else
        {
            return false;
        }
    }
}




















Home »
  C# Tutorial »
    Data Types »




C# Data Types
Bool
Byte
Char
Decimal
Double
Float
Integer
Long
Short
String
C# Array
Array Example
Byte Array
C# Standard Data Type Format
BigInteger
Complex
Currency
DateTime
DateTimeOffset
DateTime Format Parse Convert
TimeSpan
TimeZone
Enum
Null
tuple
var