Пример #1
0
        // Function to check a key.
        public static void CheckKey(MyDictionary <int, AbstrState> myDictionary)
        {
            Console.Clear();

            bool ok;
            int  key;

            do
            {
                Console.Write("Enter the key: ");
                ok = Int32.TryParse(Console.ReadLine(), out key);
                if (!ok)
                {
                    Console.WriteLine("Input error! Perhaps you didn't enter a number");
                }
            } while (!ok);

            ok = myDictionary.ContainsKey(key);

            if (ok)
            {
                Console.WriteLine("There is an element with this key!");
            }
            else
            {
                Console.WriteLine("There is no element with this key");
            }

            Console.WriteLine("Press ENTER to continue");
            Console.ReadLine();
        }