I have a list that contains item like below:
Now I want to group according to language index (Languages[x]
) like below:
Group-1:
model.Languages[0].Employer
model.Languages[0].Title
Group-2:
model.Languages[1].Employer
model.Languages[1].Title
Can AnyBody tell me how can I do this?
You can use Regex to extract the key:
var grouped = languages.GroupBy(l => Regex.Match(l, @"Languages\[\d+\]").Value);