SortedList<int, string> months = new SortedList<int, string>();
SortedList<int, SortedList> all = new SortedList<int, SortedList>();我想创建一个SortedList,它包含另一个排序的'months‘类型列表,如上面的代码片段所示。
months.Add(1, "January");
all.Add(2012,months);我得到了错误
无法从'System.Collections.Generic.SortedList‘转换为'System.Collections.SortedList’
我很困惑..。
发布于 2012-05-05 17:53:15
您忘记了为内部SortedList指定类型参数,它发现了一个非泛型参数,这是一个不同的类型。执行以下操作:
var all = new SortedList<int, SortedList<int, string>>();发布于 2012-05-05 17:54:28
你必须给你的参数命名(否则它是一个不同的类型)。试试这个:
SortedList<int, SortedList<int, string> > all = new SortedList<int, SortedList<int, string> >(); https://stackoverflow.com/questions/10460684
复制相似问题