how to fetch data from nested Dictionary in c#

前端 未结 5 1076
一向
一向 2020-12-19 14:09

I need to fetch data from nested Dictionary IN C#. My Dictionary is like this:

static Dictionary&         


        
5条回答
  •  难免孤独
    2020-12-19 14:35

    A LINQ answer (that reads all the triples):

    var qry = from outer in allOffset
              from inner in outer.Value
              select new {OuterKey = outer.Key,InnerKey = inner.Key,inner.Value};
    

    or (to get the string directly):

    var qry = from outer in allOffset
              from inner in outer.Value
              select outer.Key + "->>" + inner.Key + ", " + inner.Value;
    
    foreach(string s in qry) { // show them
        Console.WriteLine(s);
    }
    

提交回复
热议问题