Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

C# - ArrayList Class

using System;
using System.Collections;

namespace CollectionApplication {
   
   class Program {
      
      static void Main(string[] args) {
         ArrayList al = new ArrayList();
         string a;
         Console.WriteLine("Adding some numbers:");
         
         a="1";
         al.Add(a);
         a="2";
         al.Add(a);
         a="3";
         al.Add(a);

         
         Console.WriteLine("Capacity: {0} ", al.Capacity);
         Console.WriteLine("Count: {0}", al.Count);
         
         Console.Write("Content: ");
         foreach (string i in al) {
            Console.Write(i + " ");
         }
         
         Console.WriteLine();
         Console.Write("Sorted Content: ");
         al.Sort();
         foreach (string i in al) {
            Console.Write(i + " ");
         }
         Console.WriteLine();
         Console.ReadKey();
      }
   }
}

Advertisements
Loading...

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.