// Takes a CityName param and returns that city info from dictionary as ...? CityInfo? public CityInfo DisplayCityInformation(string CityName) { // find city in cata by name CityInfo city = CityCatalogue.Where(c => c.Key == CityName) as CityInfo; return(city); }
// Returns the sum of all cities populations from Dictionary public int CalculateProvincePopulation(string ProvinceName) { int TotalPop = 0; // for each city in given province foreach (var c in CityCatalogue.Where(city => city.Value.Province == ProvinceName).ToList()) { TotalPop += c.Value.Population; } return(TotalPop); }
// Takes a ProvinceName param and retuns a list of all cities located in that province from the dictionary public List <CityInfo> DisplayProvinceCities(string province) { return(CityCatalogue.Where(c => c.Value.Province == province).Select(c => c.Value).ToList()); }