using System.Collections.Generic;
public static void Main()
List<CityPopulationModel> data = new List<CityPopulationModel>();
Console.WriteLine("Population per City\n===================");
data.Add(new CityPopulationModel { Name = "Manila", Region = "NCR", Population = 10000 });
data.Add(new CityPopulationModel { Name = "Muntinlupa", Region = "NCR", Population = 20000 });
data.Add(new CityPopulationModel { Name = "Iloilo", Region = "Region6", Population = 30000 });
data.Add(new CityPopulationModel { Name = "Bacolod", Region = "Region6", Population = 40000 });
data.Add(new CityPopulationModel { Name = "Cebu", Region = "Region7", Population = 50000 });
data.ForEach((x) => Console.WriteLine("Name: {0,-15} Region: {1,-10} Pop: {2,10}", x.Name, x.Region, x.Population));
Console.WriteLine("\nPopulation per Region\n=====================");
.Select(g=>new { Region = g.Key, Population = g.Sum(x=>x.Population)})
dataPerRegion.ForEach((x) => Console.WriteLine("Region: {0,-10} Pop: {1,10}", x.Region, x.Population));
public class CityPopulationModel
public string Name {get;set;}
public string Region {get;set;}
public int Population {get;set;}