using System;
using System.Collections.Generic;
namespace ConsoleApplication2
{
public delegate int DelegateOne<T>(T a, T b);
internal class Program
{
public static void Main(string[] args)
{
string[] ints = {"aff","z","fdsd","aaaaaa","yes"};
var max = GetMax(ints, delegate(string a, string b)
{
return a.Length - b.Length;
});
// int[] ints = {3, 2, 54, 23, 222, 9999};
// var max = GetMax(ints, (o, oo) => o.CompareTo(oo));
Console.WriteLine(max);
}
static T GetMax<T>(T[]arr, DelegateOne<T> del)
{
T max = arr[0];
foreach (T t in arr)
{
if (del(max, t) < 0)
{
max = t;
}
}
return max;
}
}
}