using System.Collections.Generic;
public static void Main()
List<MyItem> l = new List<MyItem>();
l.Add(new MyItem(){person_id = 1, person_name = "Jim", shirt = "green", cost = 10});
l.Add(new MyItem(){person_id = 1, person_name = "Jim", shirt = "yellow", cost = 20});
l.Add(new MyItem(){person_id = 1, person_name = "Jim", shirt = "blue", cost = 30});
l.Add(new MyItem(){person_id = 2, person_name = "John", shirt = "red", cost = 40});
l.Add(new MyItem(){person_id = 2, person_name = "John", shirt = "orange", cost = 50});
l.Add(new MyItem(){person_id = 3, person_name = "Joe", shirt = "purple", cost = 60});
var groupedList = l.GroupBy(x => new { x.person_id, x.person_name });
foreach(var groupedItem in groupedList)
Display(groupedItem.Key.person_id);
Display(groupedItem.Key.person_name);
foreach(var item in groupedItem)
public static void Display(object obj)
public int person_id { get; set; }
public string person_name { get; set; }
public string shirt { get; set; }
public int cost { get; set; }