1

我有这样的方法:

public static void Fill<T> (this DropDownList control,
   Expression<Func<T, object>> value,      
   Expression<Func<T, bool>> whereClause = null,
   Expression<Func<T, object>> orderClause = null,
   string selectedvalue = null) where T : class
{}

到目前为止一切顺利......但我需要在 Where 和 Order 子句中添加 List 选项,所以我添加了更多 3 个新方法:

public static void Fill<T> (this DropDownList control,
   Expression<Func<T, object>> value,      
   IList<Expression<Func<T, bool>>> listWhereClause = null,
   IList<Expression<Func<T, object>>> listOrderClause = null,
   string selectedvalue = null) where T : class
{}

public static void Fill<T> (this DropDownList control,
   Expression<Func<T, object>> value,      
   IList<Expression<Func<T, bool>>> listWhereClause = null,
   Expression<Func<T, object>>> orderClause = null,
   string selectedvalue = null) where T : class
{}

public static void Fill<T> (this DropDownList control,
   Expression<Func<T, object>> value,      
   Expression<Func<T, bool>>> whereClause = null,
   IList<Expression<Func<T, object>>> listOrderClause = null,
   string selectedvalue = null) where T : class
{}

现在的问题是我得到了不明确的调用错误......解决这个问题的最佳选择是什么(不增加方法计数)?

4

1 回答 1

5

删除重载的默​​认值 ( null)。因为您已经添加了默认null值的重载,所以编译器根本不知道要使用哪一个。

于 2013-06-06T16:54:25.367 回答