关于C# 动态数组 ArrayList

关于C# 动态数组 ArrayList

using System.Collections;

        static void Main(string[] args)
        {
            TestArrayList();
        }

        //------------------------------------------------------
        // 动态数组(ArrayList)

        public static void TestArrayList()
        {
            ArrayList arr = new ArrayList();
            arr.Add(1);
            arr.Add(5);
            arr.Add(3);

            Console.WriteLine("Capacity: {0} ", arr.Capacity);
            Console.WriteLine("Count: {0}", arr.Count);

            Console.Write("Content: ");
            foreach (int i in arr)
            {
                Console.Write(i + " ");
            }
            Console.WriteLine();
            Console.Write("Sorted Content: ");
            arr.Sort();
            foreach (int i in arr)
            {
                Console.Write(i + " ");
            }
            Console.WriteLine();
            Console.ReadLine();
        }
        //------------------------------------------------------

 

发表回复

您的电子邮箱地址不会被公开。