簡體   English   中英

如果我有字典<string,list<int,int> &gt;如何在 c# 中訪問此列表的密鑰? </string,list<int,int>

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

我想打印列表的所有鍵,即排序字典的值。

 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);

    }
}

以下代碼將執行此操作:

  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);
        }
     }
  }

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM