【发布时间】:2013-02-19 20:44:00
【问题描述】:
我正在尝试返回接口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>”。存在显式转换(您是否缺少演员表?)
【问题讨论】:
-
这是什么语言?
-
C# ....................
-
您能否更新您的问题以显示完整的方法以及完整的错误?
标签: c# collections