-1

I got list of Issues, Where Issue

public class Issue
{
    public string version{ get; set; }
    public string someDescription { get; set; }
}

versions are duplicated e.g:

List<
     {"1.2.8", value1},
     {"1.3.1", value2},
     {"1.2.8", value3}
     >

and I need to split duplicates into dictionary, where key is a specific verison, and value is a list of values like:

Dictionary<stirng, List<string>> duplicates; 
what mean Dictionary<EachVersion, List<valuesForThisVersion>>

got something like this:

var VerisonList = records.GroupBy(r => r.Verison).Select(w=>w.Key).ToList();

this give me a list of versions, but have no idea how to fast get list of values where verison == VerisonList.element;

Is it possible with one linq?

EDIT: This is NOT a duplicate of the other question. In linked post there is no answer for my problem!!

EmerG
  • 1,046
  • 8
  • 13

1 Answers1

0

Sure, using ToDictionary():

records.GroupBy(r => r.Verison)
       .ToDictionary(g => g.Key, 
                     g => g.Select(i => i.someDescription).ToList());
D Stanley
  • 149,601
  • 11
  • 178
  • 240