我有一个ILookup<Type, (int, string, BitmapSource)>,它应该在下拉列表中存储元素的显示信息(否则只能作为枚举存在于应用程序中)。
元组的访问方式如下:
public IEnumerable<(int, string, BitmapSource)> EnumerationValues(Type type)
{
return this._enumerationValues
.Where(group => group.Key == type)
.Select(group => group.SelectMany<(int, string, BitmapSource),
(int, string, BitmapSource)>(element => element));
}但是,编译器对此表示不满:
无法将lambda表达式转换为指定的委托类型,因为块中的某些返回类型不能隐式转换为委托返回类型。
甚至编写element => (element.Item1, element.Item2, element.Item3)也会导致同样的错误。我在这里做错了什么,类型完全一样。
发布于 2018-10-25 17:23:09
获取与给定键关联的值的方法是使用索引器。这是专门为返回与该键关联的值序列而设计的操作。尝试在整个集合中搜索匹配的键,首先就不能实现查找的全部目的,因为它是专门为快速搜索给定键而设计的数据结构。
public IEnumerable<(int, string, BitmapSource)> EnumerationValues(Type type) =>
_enumerationValues[type];https://stackoverflow.com/questions/52994582
复制相似问题