我正在创建一些扩展方法,但 RadComboBoxItemCollection 出现了一些错误,RadComboBoxItemCollection 似乎实现了 IEnumerable 但 linq 不断给我错误说:
“找不到源类型'Telerik.Web.UI.RadComboBoxItemCollection'的查询模式的实现。找不到'Where'。考虑明确指定范围变量'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'”