好吧,我迷路了。爲什麼第一個函數WRONG(在lambda表達式中是波浪狀的),但是第二個函數是RIGHT(意味着它編譯)?無法將表達式類型'lambda表達式'轉換爲返回類型'System.Linq.Expressions.Expression <System.Func <IProduct,string,bool >>'
public static Expression<Func<IProduct, string, bool>> IsValidExpression(string val)
{
return (h => h.product_name == val);
}
public static Expression<Func<IProduct, bool>> IsValidExpression2()
{
return (m => m.product_name == "ACE");
}
那麼該函數沒有使用第二個參數,所以我會說這不是_needed_但是該方法的簽名是錯誤的 – 2010-01-11 22:42:18
同意。說明它的簡潔方式。 – womp 2010-01-11 22:46:35
這不會編譯,btw ...需要'(h,i)=>' – 2010-01-11 22:51:52