Exemplo n.º 1
0
        public static Dictionary <string, Nomos> GetNomoi()
        {
            var nomoi = new Dictionary <string, Nomos>();

            var nomos = new Nomos("Athina", 576, 334);

            nomoi.Add("Attiki", nomos);
            nomos = new Nomos("Katerini", 80, 21);
            nomoi.Add("Pieria", nomos);
            nomos = new Nomos("Volos", 56, 8);
            nomoi.Add("Magnisia", nomos);

            return(nomoi);
        }
        static void Main(string[] args)
        {
            //Constructor class Dictionary                                    //string string ---pair of key value
            Dictionary <string, string> capitals = new Dictionary <string, string>();

            capitals.Add("Attiki", "Athina");
            capitals.Add("Pieria", "Katerini");
            capitals.Add("Magnisia", "Volos");
            capitals.Add("Imathias", "Veroia");

            string capitalOfAttiki = capitals["Attiki"];    //---[magic string]

            Console.WriteLine("The capital of Attiki is {0}", capitalOfAttiki);

            var nomoi  = Nomos.GetNomoi();
            var attiki = nomoi["Attiki"];

            Console.WriteLine("The capital of Attiki is {0}, population is {1}", attiki.Capital, attiki.Population);
        }