using System.Collections.Generic;
public static void Main()
var s = new List<SampleObject>();
PgId = new List<string> { "A", "B", "C" },
PgId = new List<string> { "A", "B", "C" },
PgId = new List<string> { "l", "h", "m" },
var result = s.GroupBy(y => y.MsfId)
.Select(y => new SampleObject
PgId = y.SelectMany(g => g.PgId).Distinct().ToList(),
foreach (var item in result)
Console.WriteLine(item.MsfId);
foreach (var item1 in item.PgId)
Console.WriteLine(item1);
public class SampleObject
public int MsfId { get; set; }
public List<string> PgId { get; set; }
public List<string> DcId { get; set; }