繁体   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