public void DeckStats_Click(object obj) { var dekcStatisticalDic = new Dictionary <int, int>(); var costIgList = _deckVm.IgModels.Select(deckEntity => deckEntity.Cost); var costUgList = _deckVm.UgModels.Select(deckEntity => deckEntity.Cost); var costDeckList = new List <int>(); costDeckList.AddRange(costIgList); costDeckList.AddRange(costUgList); var costMax = costDeckList.Max(); for (var i = 0; i != costMax + 1; i++) { dekcStatisticalDic.Add(i + 1, costDeckList.Count(cost => cost.Equals(i + 1))); } DialogUtils.ShowDekcStatistical(dekcStatisticalDic); }