标签:bsp code eric 委托 aaa .com max one ons
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; } } }
标签:bsp code eric 委托 aaa .com max one ons
原文地址:http://www.cnblogs.com/zhaoxianglong1987/p/7624369.html