我试图返回接口IDictionary
(与字符串键和列表值)像:返回的IDictionary <字符串,ICollection的<ValueSet>>
IDictionary<string, ICollection<ValueSet>> method(...) {
}
从方法的内部创建的字典对象:
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>'。存在明确的转换(您是否缺少演员?)
这是什么语言? – 2013-02-19 20:44:49
C#........................ – user2047824 2013-02-19 20:51:24
您是否可以更新您的问题以显示完整的方法以及完整的错误? – cepatt 2013-02-19 20:57:40