简体   繁体   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#?

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何转换清单 <string> 到字典 <string, int> ? - How can I transform a List <string> to a Dictionary<string, int>? 字典 <string, int> 列出 <Dictionary<string, int> &gt;在C#中 - Dictionary<string, int> to List<Dictionary<string, int>> in c# 如何订购字典列表 <int, string> 基于Dictionary int值? - How can I order a List of Dictionary<int, string> based on Dictionary int value? 如何创建字典副本 <int,List<int> &gt;而不影响原始(C#)? - How do I create a copy of a Dictionary<int,List<int>> without affecting the original (C#)? 如何访问列表 <KeyValuePair<string,int> &gt;来自MongoDB - How can I access List<KeyValuePair<string,int>> from MongoDB 如何在C#中为字典使用委托 <int, List<string> &gt; - How to use Delegate in C# for Dictionary<int, List<string>> 如何将 string[] 转换为列表<int> ? - How I can convert string[] to list<int>? 如何按清单分组 <int> 在字典中 <string, List<int> &gt;列表相同的地方? - How do I group by List<int> in a Dictionary<string, List<int>> where the lists are identical? 如何检查字符串s是否在列表中 <string> 在字典中 <int, List<string> &gt;在C#中? - How to check if string s is inside of the List<string> in Dictionary<int, List<string>> in c#? 我如何反序列化json字符串列表 <Dictionary<string,int> &gt;使用JQuery? - How can I deserialize a json string List<Dictionary<string,int>> using JQuery?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM