日期:2014-05-17 浏览次数:20756 次
public class Test { public static void A<T>(T a) { Console.WriteLine("A1"); } public static void A<T>(T a, T b) { Console.WriteLine("A2"); } }
public static IQueryable<TResult> Select<TSource, TResult>(this IQueryable<TSource> source, Expression<Func<TSource, int, TResult>> selector); public static IQueryable<TResult> Select<TSource, TResult>(this IQueryable<TSource> source, Expression<Func<TSource, TResult>> selector);
Type[] generictypes = null; ParameterInfo[] pinfos = null; MethodInfo ms = typeof(Test).GetMethods().First((p) => p.IsGenericMethod && p.Name == "A" && (generictypes = p.GetGenericArguments()).Length == 1 && generictypes[0].Name == "T" && (pinfos = p.GetParameters()).Length == 2 && pinfos[0].ParameterType == generictypes[0] && pinfos[1].ParameterType == generictypes[0]);