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這是一個有趣的解決方案。:) –