我正在尝试使用方法
创建界面void Import(int id, IDictionary<int, IDictionary<int, string>> items);
然后调用此方法,如
Dictionary<int, Dictionary<int, string>> items = viewModel.Items
.GroupBy(t => t.Number)
.ToDictionary(t => t.Key, t => t.ToDictionary(x => x.LanguageId, x => x.Translation));
Import(id, items);
我预计它应该有效但却出错了
cannot convert from 'System.Collections.Generic.Dictionary<int, System.Collections.Generic.Dictionary<int, string>>' to 'System.Collections.Generic.IDictionary<int, System.Collections.Generic.IDictionary<int, string>>'
为什么我不能在这里使用interface IDictionary?我应该手动投射吗?
答案 0 :(得分:4)
更改您的分配类型。
<F, A extends Attribute<? super T, ?> & Bindable<F>> EntityGraphElement<F> fetch(A attribute);