Expression<Func<T, bool>> method argument
问题 I'm trying to make a generic method that returns the string version of an expression: public string GetExpressionString(Expression<Func<T, bool>> expr) where T: class { return exp.Body.ToString(); } Cannot resolve symbol T Works well if I change T to a hard coded type. What did I miss? 回答1: You'll need to declare T as a generic type parameter on the method: public string GetExpressionString<T>(Expression<Func<T, bool>> exp) where T: class { return exp.Body.ToString(); } // call like this