using System.Collections.Generic;
public static void Main()
Dictionary<string,string> plurals = new Dictionary<string,string>{
["Plaintiff"] = "Plaintiffs",
["Defendant"] = "Defendants",
["Witness"] = "Witnesses"
List<Party> parties = new List<Party>();
parties.Add(new Party {Type = "Plaintiff", Name = "Eilean Dover"});
parties.Add(new Party {Type = "Plaintiff", Name = "Bea O'Problem"});
parties.Add(new Party {Type = "Defendant", Name = "Anna Graham"});
parties.Add(new Party {Type = "Witness", Name = "John Doe"});
parties.Add(new Party {Type = "Witness", Name = "Rosa Shore"});
var result = string.Join(", ", parties.GroupBy(x => x.Type).Select(item => {
var prefix = item.Count()>1 ? plurals[item.Key] : item.Key;
var people = String.Join(", ", item.Select(x => x.Name));
return $"{prefix} {people}";
Console.WriteLine(result);
public string Type { get; set; }
public string Name { get; set; }