iman nasser iman nasser - 2 months ago 7
C# Question

I am using Dictionary with list and tuple,how can read items of list

I am using Dictionary with tuple as a parameter.

Dictionary<int, List<Tuple<string, int>>> dict =
new Dictionary<int,List<Tuple<string,int>>>();


how can read list items .

Thanks in Advance.

Answer
foreach(var item in dict.Values)
{
      foreach(var tuple in item)
      {
            var someString = tuple.Item1;
            var someInt = tuple.Item2;
      }
}

edit: or this

   var someList = dict[SOME KEY];

   foreach(var tuple in someList)
      {
            var someString = tuple.Item1;
            var someInt = tuple.Item2;
      }
Comments