简体   繁体   中英

if i have a dictionary<string,list<int,int>>how can i access the key of this list in c#?

I want to print all the key of the list which is the value of the sorted dictionary.

 SortedDictionary<string, object> dict2 = new SortedDictionary<string, object>();
 SortedList<int, int> innerdict2= new SortedList<int, int>();

foreach(var k in dict2)
{
    foreach(var item in k.value)
    {
        console.writeline(item);

    }
}

Following code will do it:

  static void Main()
  {
     SortedDictionary<string, SortedList<int, int>> dict2 = new SortedDictionary<string, SortedList<int, int>>();

     // TODO: Fill in data

     foreach (var k in dict2)
     {
        foreach (var item in k.Value)
        {
           Console.WriteLine(item.Key);
        }
     }
  }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM