我正在尝试返回接口IDictionary
(带有字符串键和列表值),例如:
IDictionary<string, ICollection<ValueSet>> method( ...) {
}
从方法内部创建 Dictionary 对象:
var dic = new Dictionary <string, List <ValueSet> >();
一切正常,但我不能在dic
这里返回对象。我不能隐式转换。
我怎样才能使这件事起作用?
public IDictionary < string, ICollection < ValueSet > > GetValueSets(ICollection < string > contentSetGuids)
{
var dic = new Dictionary < string, List < ValueSet > > ();
using (SqlCommand command = new SqlCommand())
{
StringBuilder sb = new StringBuilder(ValueSet.ValueSetQueryText);
sb.Append(" where contentsetguid ");
sb.Append(CreateInClause(contentSetGuids));
command.CommandText = sb.ToString();
dic = GetObjects(command).GroupBy(vs => vs.ContentSetGuid).ToDictionary(grp => grp.Key, grp => grp.ToList());
}
return dic;
}
错误:错误 46 无法将类型“System.Collections.Generic.IDictionary>”隐式转换为“System.Collections.Generic.IDictionary>”。存在显式转换(您是否缺少演员表?)