static void Main(string[] args)
        {
            MyDictionary <int, string> dict1 = new MyDictionary <int, string>();

            Console.WriteLine("Please enter you key and value respesctively: ");
            Console.WriteLine("Press '0' to exit.");

            while (true)
            {
                int    key;
                string value;
                key = Convert.ToInt32(Console.ReadLine());
                if (key == 0)
                {
                    break;
                }
                value = Console.ReadLine();
                dict1.Add(key, value);
            }

            dict1.Print();
        }
示例#2
0
        static void Main(string[] args)
        {
            MyDictionary <int, string> myDictionary = new MyDictionary <int, string>();

            Console.WriteLine("Please enter you key and value respesctively: ");
            Console.WriteLine("Press '0' to exit.");

            while (true)
            {
                int    key;
                string value;
                key = Convert.ToInt32(Console.ReadLine());
                if (key == 0)
                {
                    break;
                }
                value = Console.ReadLine();
                myDictionary.Add(key, value);

                break;
            }
            Console.WriteLine(myDictionary.Length()); // to control if it is working properly, or not?
        }