4
我正在构建一些Linq表达式并试图获取IEnumerable.DefaultIfEmpty
(http://msdn.microsoft.com/en-us/library/bb360179.aspx)的MethodInfo。什么似乎是一件容易的事,但我无能为力,为什么它不工作。获取Enumerable.DefaultIfEmpty的方法信息
typeof(Enumerable).GetMethod("DefaultIfEmpty", new[] { typeof(IEnumerable<>) });
typeof(Enumerable).GetMethod("DefaultIfEmpty", new[] { typeof(IEnumerable<>).MakeGenericType(typeof(WorkitemListModel)) });
相关,但不是一个笨蛋:http://stackoverflow.com/questions/3631547/select -right-generic-method-with-reflection/3632196#3632196 – LukeH
@LukeH这是一个有趣的解决方案。:) –