Пример #1
0
        //  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);
        }
Пример #2
0
        //  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);
        }
Пример #3
0
 //  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());
 }