示例#1
0
        static void Main(string[] args)
        {
            List <Kangaroo> kangaroos = new List <Kangaroo>();

            Kangaroo k1 = new Kangaroo
            {
                name   = "Jack",
                age    = 5,
                color  = "brown",
                gender = "M"
            };
            Kangaroo k2 = new Kangaroo
            {
                name   = "Lili",
                age    = 3,
                color  = "red",
                gender = "W"
            };

            kangaroos.Add(k1);
            kangaroos.Add(k2);

            //foreach (var item in kangaroos)
            //{
            //    Console.WriteLine(item);
            //}

            k1.PutInBox(k2);


            Console.WriteLine();
            k1.GetFromBox();

            Queue <int> qint = new Queue <int>();

            qint.Enqueue(2);
            qint.Enqueue(5);
            qint.Enqueue(6);
            qint.Enqueue(1);

            for (var i = 0; i < qint.Count; i++)
            {
                qint.Dequeue();
            }
            List <int> nums = new List <int>();

            nums.AddRange(new int[7] {
                1, 8, 3, 9, 20, 11, 0
            });

            //for (int i = 0; i < nums.Count; i++)
            //{
            //    nums[i] *= 10;
            //}

            nums.Sort();

            nums.Insert(2, 5);

            for (int i = 0; i < nums.Count; i++)
            {
                Console.Write(nums[i] + " ");
            }
        }
示例#2
0
        static void Main(string[] args)
        {
            Console.WriteLine("Hello Zoo!\n");

            Parrot p = new Parrot("Vasyz", 5, "Red");
            //Parrot p2 = new Parrot("Valera", 1, "White");


            //Animals["102"].name = "Kolya";

            ////Console.WriteLine(Animals.ContainsKey("102"));
            ////Console.WriteLine(Animals.ContainsKey("105"));


            //// Console.WriteLine(Animals.ContainsValue(p2));

            //Animals.Remove("102");

            //foreach (var item in Animals)
            //{
            //    Console.WriteLine(item.Key);
            //    Console.WriteLine(item.Value.name);
            //    Console.WriteLine(item.Value.color);
            //    Console.WriteLine();
            //}


            List <Kangaroo> kangaroos = new List <Kangaroo>();

            Kangaroo k1 = new Kangaroo
            {
                name   = "Jack",
                age    = 5,
                color  = "brown",
                gender = "M"
            };
            Kangaroo k2 = new Kangaroo
            {
                name   = "Lili",
                age    = 3,
                color  = "red",
                gender = "W"
            };

            kangaroos.Add(k1);
            kangaroos.Add(k2);

            //foreach (var item in kangaroos)
            //{
            //    Console.WriteLine(item);
            //}

            k1.PutInBox(k2);
            k1.PutInBox(p);

            Console.WriteLine();
            k1.GetFromBox();

            Queue <int> qint = new Queue <int>();

            qint.Enqueue(2);
            qint.Enqueue(5);
            qint.Enqueue(6);
            qint.Enqueue(1);

            for (var i = 0; i < qint.Count; i++)
            {
                qint.Dequeue();
            }
            //List<int> nums = new List<int>();

            //nums.AddRange(new int[7] { 1, 8, 3, 9, 20, 11, 0 });

            ////for (int i = 0; i < nums.Count; i++)
            ////{
            ////    nums[i] *= 10;
            ////}

            //nums.Sort();

            //nums.Insert(2, 5);

            //for (int i = 0; i < nums.Count; i++)
            //{
            //    Console.Write(nums[i]+ " ");
            //}
        }