using System.Collections.Generic;
using System.Collections.ObjectModel;
public int f1 {get; set;}
public bool f2 {get; set;}
public static void Main()
public static Dictionary<int, ReadOnlyCollection<Struct>> func() {
var list = (new List<Struct> { new Struct { f1 = 10, f2 = false}, new Struct { f1 = 10, f2 = true}, new Struct { f1 = 11, f2 = false}, new Struct { f1 = 11, f2 = true} });
var groupped = from l in list
group l by l.f1 into lgroup
select new { key = lgroup.Key, value = lgroup.Select(x=> x) };
return groupped.ToDictionary(x=>x.key, x=>x.value.ToList().AsReadOnly());