0
SortedList<int, string> months = new SortedList<int, string>();
SortedList<int, SortedList> all = new SortedList<int, SortedList>();

上記のコード スニペットのように、「月」タイプの別のソート済みリストを含む SortedList を作成したいと考えています。

months.Add(1, "January");
all.Add(2012,months);

エラーが発生します

「System.Collections.Generic.SortedList」から「System.Collections.SortedList」に変換できません

私は混乱しています...

4

2 に答える 2

3

inner の型引数を指定するのを忘れてSortedList、別の型である非ジェネリックなものが見つかりました。これを行う:

var all = new SortedList<int, SortedList<int, string>>();
于 2012-05-05T09:53:14.897 に答える
0

パラメータに名前を付ける必要があります (そうしないと、別の型になります)。これを試して:

SortedList<int, SortedList<int, string> > all = new SortedList<int, SortedList<int, string> >(); 
于 2012-05-05T09:54:27.503 に答える