Array.FindAll Method: This is the syntax of the Predicate delegate:delegate bool Predicate(T obj)
using System;
using System.Collections;
using System.Collections.Generic;
public class MainClass {
public static void Main() {
int[] zArray = { 1, 2, 3, 1, 2, 3, 1, 2, 3 };
Predicate<int> match = new Predicate<int>(MethodA<int>);
int[] answers = Array.FindAll(zArray, match);
foreach (int answer in answers) {
Console.WriteLine(answer);
}
}
public static bool MethodA<T>(T number) where T : IComparable {
int result = number.CompareTo(3);
return result == 0;
}
}
Related examples in the same category