【发布时间】:2009-08-11 16:42:40
【问题描述】:
我正在创建一些扩展方法,但在使用 RadComboBoxItemCollection 时遇到了一些错误,RadComboBoxItemCollection 似乎实现了 IEnumerable 但 linq 一直给我错误提示:
"找不到实现 源类型的查询模式 'Telerik.Web.UI.RadComboBoxItemCollection'。 '哪里' 没有找到。考虑 明确指定的类型 范围变量‘myItem’。”
从此代码
public static bool ContainsValue(this RadComboBoxItemCollection myList, string value)
{
bool matches = (from myItem in myList where myItem.Value == value select myItem).Count() > 0;
return matches;
}
另一方面,RadListBoxItemCollection 工作得很好
public static bool ContainsValue(this IEnumerable<RadListBoxItem> myList, string value)
{
bool matches = (from myItem in myList where myItem.Value == value select myItem).Count() > 0;
return matches;
}
我尝试做 IEnumerable,这解决了 linq 错误,但我得到了这个错误
"实例参数:无法转换 从 'Telerik.Web.UI.RadComboBoxItemCollection' 到 'System.Collections.Generic.IEnumerable'"
【问题讨论】:
标签: linq extension-methods telerik