الأربعاء، 27 أبريل 2011

last quiz solution


below is nearly a  suggested solution for the last quiz, there are a bit differences , but idea is identical
good luck for all




using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;

namespace Hash_ArrayListPro
{
    class Program
    {
        public static Hashtable geo_info = new Hashtable(); 
        static void Main(string[] args)
        {
            for (int i = 0; i < 3; i++) 
            {
                Console.WriteLine("Enter country ");
                string country = Console.ReadLine();

                Console.WriteLine("Enter country area");
                object area = Console.ReadLine();

                geo_info.Add(country, area);


            } // end for

            Console.WriteLine("Geographic information are:");
            foreach (Object Key in geo_info.Keys)
            {
                Console.WriteLine(" {0} Area is :  {1}", Key, geo_info[Key]);

            }

            Console.WriteLine("enter the country name you want to modify its area");

            string key1 = Console.ReadLine();
            if (geo_info.Contains(key1))
            {
                geo_info[key1] = 111.1111;

                Console.WriteLine("Geographic information After Modification:");
                foreach (Object Key in geo_info.Keys)
                {
                    Console.WriteLine(" {0} Area is :  {1}", Key, geo_info[Key]);

                }
            }
            else
            {
                Console.WriteLine("Not exists Country");
            }
            
            
            ArrayList list = new ArrayList();
            list.Add("ali");
            list.Add(88);
            list.Add('B');

            foreach (object x in list)
                Console.WriteLine(x);


            Console.WriteLine(list.Count);

            Console.ReadLine();
            list.Insert(1,"hasan");
            list.Reverse();
            foreach (object x in list)
                Console.WriteLine(x);
  




        }// end main
    }
}

ليست هناك تعليقات:

إرسال تعليق