Beispiel #1
0
        static void Main(string[] args)
        {
            KeyedArray ma = new KeyedArray(100);

            ma["Bart"]   = 8;
            ma["Lisa"]   = 10;
            ma["Maggie"] = 2;

            Console.WriteLine("Let's find Lisa's age");
            int age = (int)ma["Lisa"];

            Console.WriteLine("Lisa is {0}", age);

            Console.WriteLine("Press Enter to terminate...");
            Console.Read();
        }
Beispiel #2
0
        public static void Main(string[] args)
        {
            // create an array with enough room
            KeyedArray ma = new KeyedArray(100);

            // save off the ages of the Simpsons' kids
            ma["Bart"]   = 8;
            ma["Lisa"]   = 10;
            ma["Maggie"] = 2;

            // look up the age of Lisa
            Console.WriteLine("Let's find Lisa's age");
            int age = (int)ma["Lisa"];

            Console.WriteLine("Lisa is {0}", age);

            // wait for user to acknowledge the results
            Console.WriteLine("Press Enter to terminate...");
            Console.Read();
        }
Beispiel #3
0
        public static void Main(string[] args)
        {
            // Create a KeyedArray for ints (now generic).
            KeyedArray <int> ka = new KeyedArray <int>();

            // Save the ages of the Simpsons' kids.
            ka["Bart"]   = 8;
            ka["Lisa"]   = 10;
            ka["Maggie"] = 2;

            // Look up the age of Lisa.
            Console.WriteLine("Let's find Lisa's age");
            int age = ka["Lisa"];

            Console.WriteLine("Lisa is {0}", age);

            // Replace Bart's age with a new value (Bart already in list).
            ka["Bart"] = 108;
            Console.WriteLine(ka["Bart"]);

            // Wait for user to acknowledge the results.
            Console.WriteLine("Press Enter to terminate...");
            Console.Read();
        }
Beispiel #4
0
    public static void Main(string[] args)
    {
      // Create an array with enough room.
      KeyedArray ma = new KeyedArray(100);

      // Save the ages of the Simpsons' kids.
      ma["Bart"] = 8;
      ma["Lisa"] = 10;
      ma["Maggie"] = 2;

      // Look up the age of Lisa.
      Console.WriteLine("Let's find Lisa's age");
      int age = (int)ma["Lisa"];
      Console.WriteLine("Lisa is {0}", age);

      // Wait for user to acknowledge the results.
      Console.WriteLine("Press Enter to terminate...");
      Console.Read();
    }