C#委托之泛型
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication2 { class Program { public delegate int ceshi<T>(T o1, T o2); static void Main(string[] args) { string[] o = { "abCdeg", "ssxAf" }; string xa= zheng<string>(o, delegate(string o1, string o2) { string num1 = (string)o1; string num2 = (string)o2; return num1.Length - num2.Length; }); Console.WriteLine(xa); Console.ReadKey(); } public static T zheng<T>(T[] name, ceshi<T> aaax) { T max = name[0]; for (int i = 0; i < name.Length; i++) { //max-name[i]<0 if (aaax(max, name[i]) < 0) { max = name[i]; } } return max; } } }