using System.Collections.Generic;
using System.Linq.Expressions;
public static void Main()
var list = new List<Item>();
list.Add(Create(Letter.A));
list.Add(Create(Letter.B));
list.Add(Create(Letter.C));
list.Add(Create(Letter.C));
var dict = list.Percentage(x => x.Letter1);
private static Item Create(Letter letter)
public static class Extensions
public static Dictionary<TProperty, double> Percentage<T, TProperty>(this IEnumerable<T> source, Expression<Func<T,TProperty>> selector)
var dict = new Dictionary<TProperty, double>();
Func<T,TProperty> func = selector.Compile();
var list = source.ToList();
var groups = list.GroupBy(func).ToList();
double total = list.Count;
foreach(var group in groups)
double groupCount = group.Count();
var percentage = (groupCount / total) * 100;
dict.Add(group.Key, percentage);
public Letter Letter1 {get;set;}