<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ru">
		<id>http://nfex.ru/index.php?action=history&amp;feed=atom&amp;title=Csharp%2FCSharp_Tutorial%2FData_Structure%2FArrayList</id>
		<title>Csharp/CSharp Tutorial/Data Structure/ArrayList - История изменений</title>
		<link rel="self" type="application/atom+xml" href="http://nfex.ru/index.php?action=history&amp;feed=atom&amp;title=Csharp%2FCSharp_Tutorial%2FData_Structure%2FArrayList"/>
		<link rel="alternate" type="text/html" href="http://nfex.ru/index.php?title=Csharp/CSharp_Tutorial/Data_Structure/ArrayList&amp;action=history"/>
		<updated>2026-04-30T04:24:34Z</updated>
		<subtitle>История изменений этой страницы в вики</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>http://nfex.ru/index.php?title=Csharp/CSharp_Tutorial/Data_Structure/ArrayList&amp;diff=5493&amp;oldid=prev</id>
		<title> в 15:31, 26 мая 2010</title>
		<link rel="alternate" type="text/html" href="http://nfex.ru/index.php?title=Csharp/CSharp_Tutorial/Data_Structure/ArrayList&amp;diff=5493&amp;oldid=prev"/>
				<updated>2010-05-26T15:31:53Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr style=&quot;vertical-align: top;&quot; lang=&quot;ru&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Предыдущая&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Версия 15:31, 26 мая 2010&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; style=&quot;text-align: center;&quot; lang=&quot;ru&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(нет различий)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
			</entry>

	<entry>
		<id>http://nfex.ru/index.php?title=Csharp/CSharp_Tutorial/Data_Structure/ArrayList&amp;diff=5494&amp;oldid=prev</id>
		<title>Admin: 1 версия</title>
		<link rel="alternate" type="text/html" href="http://nfex.ru/index.php?title=Csharp/CSharp_Tutorial/Data_Structure/ArrayList&amp;diff=5494&amp;oldid=prev"/>
				<updated>2010-05-26T12:15:44Z</updated>
		
		<summary type="html">&lt;p&gt;1 версия&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Новая страница&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==ArrayList: AddRange==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;using System;&lt;br /&gt;
using System.Collections;&lt;br /&gt;
using System.Collections.Specialized;&lt;br /&gt;
class MyClass{&lt;br /&gt;
   public string MyName=&amp;quot;&amp;quot;;   &lt;br /&gt;
}&lt;br /&gt;
class MainClass&lt;br /&gt;
{&lt;br /&gt;
  static void Main(string[] args)&lt;br /&gt;
  {&lt;br /&gt;
    ArrayList classList = new ArrayList();&lt;br /&gt;
    classList.AddRange(new MyClass[] { new MyClass(), &lt;br /&gt;
                                           new MyClass(), &lt;br /&gt;
                                           new MyClass()});&lt;br /&gt;
    Console.WriteLine(&amp;quot;Items in List: {0}&amp;quot;, classList.Count);&lt;br /&gt;
    // Print out current values. &lt;br /&gt;
    foreach(MyClass c in classList)&lt;br /&gt;
    {&lt;br /&gt;
      Console.WriteLine(&amp;quot;MyClass name: {0}&amp;quot;, c.MyName);  &lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;Items in List: 3&lt;br /&gt;
MyClass name:&lt;br /&gt;
MyClass name:&lt;br /&gt;
MyClass name:&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==ArrayList Query==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;using System;&lt;br /&gt;
using System.Collections;&lt;br /&gt;
using System.ruponentModel;&lt;br /&gt;
    public class Product&lt;br /&gt;
    {&lt;br /&gt;
        string name;&lt;br /&gt;
        public string Name&lt;br /&gt;
        {&lt;br /&gt;
            get { return name; }&lt;br /&gt;
        }&lt;br /&gt;
        decimal price;&lt;br /&gt;
        public decimal Price&lt;br /&gt;
        {&lt;br /&gt;
            get { return price; }&lt;br /&gt;
        }&lt;br /&gt;
        public Product(string name, decimal price)&lt;br /&gt;
        {&lt;br /&gt;
            this.name = name;&lt;br /&gt;
            this.price = price;&lt;br /&gt;
        }&lt;br /&gt;
        public static ArrayList GetSampleProducts()&lt;br /&gt;
        {&lt;br /&gt;
            ArrayList list = new ArrayList();&lt;br /&gt;
            list.Add(new Product(&amp;quot;C&amp;quot;, 9.99m));&lt;br /&gt;
            list.Add(new Product(&amp;quot;A&amp;quot;, 1.99m));&lt;br /&gt;
            list.Add(new Product(&amp;quot;F&amp;quot;, 2.99m));&lt;br /&gt;
            list.Add(new Product(&amp;quot;S&amp;quot;, 3.99m));&lt;br /&gt;
            return list;&lt;br /&gt;
        }&lt;br /&gt;
        public override string ToString()&lt;br /&gt;
        {&lt;br /&gt;
            return string.Format(&amp;quot;{0}: {1}&amp;quot;, name, price);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    class ArrayListSort&lt;br /&gt;
    {&lt;br /&gt;
        class ProductNameComparer : IComparer&lt;br /&gt;
        {&lt;br /&gt;
            public int Compare(object x, object y)&lt;br /&gt;
            {&lt;br /&gt;
                Product first = (Product)x;&lt;br /&gt;
                Product second = (Product)y;&lt;br /&gt;
                return first.Name.rupareTo(second.Name);&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        static void Main()&lt;br /&gt;
        {&lt;br /&gt;
            ArrayList products = Product.GetSampleProducts();&lt;br /&gt;
            products.Sort(new ProductNameComparer());&lt;br /&gt;
            foreach (Product product in products)&lt;br /&gt;
            {&lt;br /&gt;
                Console.WriteLine(product);&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Box ints into ArrayList==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;using System;&lt;br /&gt;
using System.Collections;&lt;br /&gt;
class MainClass&lt;br /&gt;
{&lt;br /&gt;
  static void Main(string[] args)&lt;br /&gt;
  {    &lt;br /&gt;
    ArrayList myInts = new ArrayList();&lt;br /&gt;
    myInts.Add(8);&lt;br /&gt;
    myInts.Add(3);&lt;br /&gt;
    myInts.Add(9);&lt;br /&gt;
    // Unbox first item.&lt;br /&gt;
    int firstItem = (int)myInts[0];&lt;br /&gt;
    // Another boxing operation!&lt;br /&gt;
    Console.WriteLine(&amp;quot;First item is {0}&amp;quot;, firstItem);&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;First item is 8&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Capacity and element count==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;using System; &lt;br /&gt;
using System.Collections; &lt;br /&gt;
 &lt;br /&gt;
class MainClass { &lt;br /&gt;
  public static void Main() { &lt;br /&gt;
    ArrayList al = new ArrayList(); &lt;br /&gt;
     &lt;br /&gt;
    Console.WriteLine(&amp;quot;Adding 6 elements&amp;quot;); &lt;br /&gt;
    al.Add(&amp;quot;C&amp;quot;); &lt;br /&gt;
    al.Add(&amp;quot;A&amp;quot;); &lt;br /&gt;
    al.Add(&amp;quot;E&amp;quot;); &lt;br /&gt;
    al.Add(&amp;quot;B&amp;quot;); &lt;br /&gt;
    al.Add(&amp;quot;D&amp;quot;); &lt;br /&gt;
    al.Add(&amp;quot;F&amp;quot;); &lt;br /&gt;
 &lt;br /&gt;
    Console.WriteLine(&amp;quot;Add enough elements to force ArrayList to grow. Adding 20 more elements&amp;quot;); &lt;br /&gt;
    &lt;br /&gt;
    for(int i=0; i &amp;lt; 20; i++) &lt;br /&gt;
      al.Add((char)(&amp;quot;a&amp;quot; + i)); &lt;br /&gt;
    Console.WriteLine(&amp;quot;Current capacity: &amp;quot; + &lt;br /&gt;
                       al.Capacity); &lt;br /&gt;
    Console.WriteLine(&amp;quot;Number of elements after adding 20: &amp;quot; + &lt;br /&gt;
                       al.Count); &lt;br /&gt;
    Console.Write(&amp;quot;Contents: &amp;quot;); &lt;br /&gt;
    foreach(char c in al) &lt;br /&gt;
      Console.Write(c + &amp;quot; &amp;quot;); &lt;br /&gt;
    Console.WriteLine(&amp;quot;\n&amp;quot;); &lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;Adding 6 elements&lt;br /&gt;
Add enough elements to force ArrayList to grow. Adding 20 more elements&lt;br /&gt;
Current capacity: 32&lt;br /&gt;
Number of elements after adding 20: 26&lt;br /&gt;
Contents: C A E B D F a b c d e f g h i j k l m n o p q r s t&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Change contents using array indexing==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;using System; &lt;br /&gt;
using System.Collections; &lt;br /&gt;
 &lt;br /&gt;
class MainClass { &lt;br /&gt;
  public static void Main() { &lt;br /&gt;
    ArrayList al = new ArrayList(); &lt;br /&gt;
     &lt;br /&gt;
    Console.WriteLine(&amp;quot;Adding 6 elements&amp;quot;); &lt;br /&gt;
    // Add elements to the array list &lt;br /&gt;
    al.Add(&amp;quot;C&amp;quot;); &lt;br /&gt;
    al.Add(&amp;quot;A&amp;quot;); &lt;br /&gt;
    al.Add(&amp;quot;E&amp;quot;); &lt;br /&gt;
    al.Add(&amp;quot;B&amp;quot;); &lt;br /&gt;
    al.Add(&amp;quot;D&amp;quot;); &lt;br /&gt;
    al.Add(&amp;quot;F&amp;quot;); &lt;br /&gt;
 &lt;br /&gt;
    // &lt;br /&gt;
    Console.WriteLine(&amp;quot;Change first three elements&amp;quot;); &lt;br /&gt;
    al[0] = &amp;quot;X&amp;quot;; &lt;br /&gt;
    al[1] = &amp;quot;Y&amp;quot;; &lt;br /&gt;
    al[2] = &amp;quot;Z&amp;quot;; &lt;br /&gt;
    Console.Write(&amp;quot;Contents: &amp;quot;); &lt;br /&gt;
    foreach(char c in al) &lt;br /&gt;
      Console.Write(c + &amp;quot; &amp;quot;); &lt;br /&gt;
    Console.WriteLine(); &lt;br /&gt;
  } &lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;Adding 6 elements&lt;br /&gt;
Change first three elements&lt;br /&gt;
Contents: X Y Z B D F&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Clear an ArrayList==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;using System;&lt;br /&gt;
using System.Collections;&lt;br /&gt;
class MainClass&lt;br /&gt;
{&lt;br /&gt;
  static void Main(string[] args)&lt;br /&gt;
  {&lt;br /&gt;
    ArrayList a = new ArrayList(10);&lt;br /&gt;
    int x = 0;&lt;br /&gt;
    a.Add( ++x);&lt;br /&gt;
    a.Add( ++x);&lt;br /&gt;
    a.Add( ++x);&lt;br /&gt;
    a.Add( ++x);&lt;br /&gt;
    a.Remove(x);&lt;br /&gt;
    &lt;br /&gt;
    a.RemoveAt(0);&lt;br /&gt;
    a.Clear();&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Create a string array and use the ICollection.CopyTo method to copy the contents of the ArrayList==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;using System;&lt;br /&gt;
using System.Collections;&lt;br /&gt;
class MainClass&lt;br /&gt;
{&lt;br /&gt;
    public static void Main(string[] args)&lt;br /&gt;
    {&lt;br /&gt;
        // Create a new ArrayList and populate it.&lt;br /&gt;
        ArrayList list = new ArrayList(5);&lt;br /&gt;
        list.Add(&amp;quot;B&amp;quot;);&lt;br /&gt;
        list.Add(&amp;quot;G&amp;quot;);&lt;br /&gt;
        list.Add(&amp;quot;J&amp;quot;);&lt;br /&gt;
        list.Add(&amp;quot;S&amp;quot;);&lt;br /&gt;
        list.Add(&amp;quot;M&amp;quot;);&lt;br /&gt;
        &lt;br /&gt;
        string[] array1 = new string[list.Count];&lt;br /&gt;
        list.CopyTo(array1, 0);&lt;br /&gt;
        Console.WriteLine(&amp;quot;Array 1:&amp;quot;);&lt;br /&gt;
        foreach (string s in array1) &lt;br /&gt;
        { &lt;br /&gt;
            Console.WriteLine(&amp;quot;\t{0}&amp;quot;,s); &lt;br /&gt;
        }&lt;br /&gt;
    &lt;br /&gt;
    }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;Array 1:&lt;br /&gt;
        B&lt;br /&gt;
        G&lt;br /&gt;
        J&lt;br /&gt;
        S&lt;br /&gt;
        M&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Filter int from ArrayList==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;using System;&lt;br /&gt;
using System.Collections.Generic;&lt;br /&gt;
using System.Text;&lt;br /&gt;
using System.Xml.Linq;&lt;br /&gt;
using System.Linq;&lt;br /&gt;
using System.Collections;&lt;br /&gt;
    class Car&lt;br /&gt;
    {&lt;br /&gt;
        public string PetName;&lt;br /&gt;
        public string Color;&lt;br /&gt;
        public int Speed;&lt;br /&gt;
        public string Make;&lt;br /&gt;
    }&lt;br /&gt;
    class Program&lt;br /&gt;
    {&lt;br /&gt;
        static void Main(string[] args)&lt;br /&gt;
        {&lt;br /&gt;
            ArrayList myStuff = new ArrayList();&lt;br /&gt;
            myStuff.AddRange(new object[] { 10, 400, 8, false, new Car(), &amp;quot;string data&amp;quot; });&lt;br /&gt;
            IEnumerable&amp;lt;int&amp;gt; myInts = myStuff.OfType&amp;lt;int&amp;gt;();&lt;br /&gt;
            &lt;br /&gt;
            foreach (int i in myInts)&lt;br /&gt;
            {&lt;br /&gt;
                Console.WriteLine(&amp;quot;Int value: {0}&amp;quot;, i);&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
    }&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Get an enumerator using the GetEnumerator() method and use it to read the elements in ArrayList==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;using System;&lt;br /&gt;
using System.Collections;&lt;br /&gt;
class MainClass&lt;br /&gt;
{&lt;br /&gt;
  public static void Main()&lt;br /&gt;
  {&lt;br /&gt;
    ArrayList myArrayList = new ArrayList();&lt;br /&gt;
    myArrayList.Add(&amp;quot;A&amp;quot;);&lt;br /&gt;
    myArrayList.Add(&amp;quot;A&amp;quot;);&lt;br /&gt;
    myArrayList.Add(&amp;quot;A&amp;quot;);&lt;br /&gt;
    myArrayList.Add(&amp;quot;A&amp;quot;);&lt;br /&gt;
    myArrayList.Add(&amp;quot;A&amp;quot;);&lt;br /&gt;
    myArrayList.Add(&amp;quot;A&amp;quot;);&lt;br /&gt;
    myArrayList.Add(&amp;quot;A&amp;quot;);&lt;br /&gt;
    myArrayList.Add(&amp;quot;A&amp;quot;);&lt;br /&gt;
    myArrayList.Add(&amp;quot;A&amp;quot;);&lt;br /&gt;
    myArrayList.Add(&amp;quot;A&amp;quot;);&lt;br /&gt;
    &lt;br /&gt;
    string[] anotherStringArray = {&amp;quot;Here&amp;quot;s&amp;quot;, &amp;quot;some&amp;quot;, &amp;quot;more&amp;quot;, &amp;quot;text&amp;quot;};&lt;br /&gt;
    myArrayList.SetRange(0, anotherStringArray);&lt;br /&gt;
    Console.WriteLine(&amp;quot;Using the GetEnumerator() method to get an enumerator&amp;quot;);&lt;br /&gt;
    IEnumerator myEnumerator = myArrayList.GetEnumerator();&lt;br /&gt;
    while (myEnumerator.MoveNext())&lt;br /&gt;
    {&lt;br /&gt;
      Console.WriteLine(&amp;quot;myEnumerator.Current = &amp;quot; + myEnumerator.Current);&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Get the number of elements==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;using System; &lt;br /&gt;
using System.Collections; &lt;br /&gt;
 &lt;br /&gt;
class MainClass { &lt;br /&gt;
  public static void Main() { &lt;br /&gt;
    ArrayList al = new ArrayList(); &lt;br /&gt;
     &lt;br /&gt;
    Console.WriteLine(&amp;quot;Initial number of elements: &amp;quot; + al.Count); &lt;br /&gt;
 &lt;br /&gt;
    Console.WriteLine(&amp;quot;Adding 6 elements&amp;quot;); &lt;br /&gt;
    // Add elements to the array list &lt;br /&gt;
    al.Add(&amp;quot;C&amp;quot;); &lt;br /&gt;
    al.Add(&amp;quot;A&amp;quot;); &lt;br /&gt;
    al.Add(&amp;quot;E&amp;quot;); &lt;br /&gt;
    al.Add(&amp;quot;B&amp;quot;); &lt;br /&gt;
    al.Add(&amp;quot;D&amp;quot;); &lt;br /&gt;
    al.Add(&amp;quot;F&amp;quot;); &lt;br /&gt;
 &lt;br /&gt;
    Console.WriteLine(&amp;quot;Number of elements: &amp;quot; + al.Count); &lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;Initial number of elements: 0&lt;br /&gt;
Adding 6 elements&lt;br /&gt;
Number of elements: 6&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Insert(), AddRange(), and InsertRange() methods==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;using System;&lt;br /&gt;
using System.Collections;&lt;br /&gt;
class MainClass&lt;br /&gt;
{&lt;br /&gt;
  public static void Main()&lt;br /&gt;
  {&lt;br /&gt;
    ArrayList myArrayList = new ArrayList();&lt;br /&gt;
    &lt;br /&gt;
    myArrayList.Add(&amp;quot;is&amp;quot;);&lt;br /&gt;
    myArrayList.Insert(1, &amp;quot;is&amp;quot;);&lt;br /&gt;
    string[] myStringArray = {&amp;quot;a&amp;quot;, &amp;quot;test&amp;quot;};&lt;br /&gt;
    myArrayList.AddRange(myStringArray);&lt;br /&gt;
    string[] anotherStringArray = {&amp;quot;Here&amp;quot;s&amp;quot;, &amp;quot;some&amp;quot;, &amp;quot;more&amp;quot;, &amp;quot;text&amp;quot;};&lt;br /&gt;
    myArrayList.InsertRange(myArrayList.Count, anotherStringArray);&lt;br /&gt;
    DisplayArrayList(&amp;quot;myArrayList&amp;quot;, myArrayList);&lt;br /&gt;
  }&lt;br /&gt;
  public static void DisplayArrayList(string arrayListName, ArrayList myArrayList)&lt;br /&gt;
  {&lt;br /&gt;
    for (int i = 0; i &amp;lt; myArrayList.Count; i++){&lt;br /&gt;
      Console.WriteLine(arrayListName + &amp;quot;[&amp;quot; + i + &amp;quot;] = &amp;quot; +&lt;br /&gt;
        myArrayList[i]);&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;myArrayList[0] = is&lt;br /&gt;
myArrayList[1] = is&lt;br /&gt;
myArrayList[2] = a&lt;br /&gt;
myArrayList[3] = test&lt;br /&gt;
myArrayList[4] = Here&amp;quot;s&lt;br /&gt;
myArrayList[5] = some&lt;br /&gt;
myArrayList[6] = more&lt;br /&gt;
myArrayList[7] = text&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Insert and remove at specific index==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;using System;&lt;br /&gt;
using System.Collections;&lt;br /&gt;
class MainClass&lt;br /&gt;
{&lt;br /&gt;
  static void Main(string[] args)&lt;br /&gt;
  {&lt;br /&gt;
    ArrayList a = new ArrayList(10);&lt;br /&gt;
    int x = 0;&lt;br /&gt;
    a.Add( ++x);&lt;br /&gt;
    a.Add( ++x);&lt;br /&gt;
    a.Add( ++x);&lt;br /&gt;
&lt;br /&gt;
    a.Remove(x);&lt;br /&gt;
    &lt;br /&gt;
    a.RemoveAt(0);&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Insert item to ArrayList by index==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;using System;&lt;br /&gt;
using System.Collections;&lt;br /&gt;
using System.Collections.Specialized;&lt;br /&gt;
class MyClass{&lt;br /&gt;
   public string MyName=&amp;quot;&amp;quot;;   &lt;br /&gt;
}&lt;br /&gt;
class MainClass&lt;br /&gt;
{&lt;br /&gt;
  static void Main(string[] args)&lt;br /&gt;
  {&lt;br /&gt;
    ArrayList classList = new ArrayList();&lt;br /&gt;
    classList.AddRange(new MyClass[] { new MyClass(), &lt;br /&gt;
                                           new MyClass(), &lt;br /&gt;
                                           new MyClass()});&lt;br /&gt;
    Console.WriteLine(&amp;quot;Items in List: {0}&amp;quot;, classList.Count);&lt;br /&gt;
    classList.Insert(2, new MyClass());&lt;br /&gt;
    Console.WriteLine(&amp;quot;Items in classList: {0}&amp;quot;, classList.Count);&lt;br /&gt;
    // Print out current values. &lt;br /&gt;
    foreach(MyClass c in classList)&lt;br /&gt;
    {&lt;br /&gt;
      Console.WriteLine(&amp;quot;MyClass name: {0}&amp;quot;, c.MyName);  &lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;Items in List: 3&lt;br /&gt;
Items in classList: 4&lt;br /&gt;
MyClass name:&lt;br /&gt;
MyClass name:&lt;br /&gt;
MyClass name:&lt;br /&gt;
MyClass name:&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==IsFixedSize and IsReadOnly properties==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;using System;&lt;br /&gt;
using System.Collections;&lt;br /&gt;
class MainClass&lt;br /&gt;
{&lt;br /&gt;
  public static void Main()&lt;br /&gt;
  {&lt;br /&gt;
    ArrayList myArrayList = new ArrayList();&lt;br /&gt;
    &lt;br /&gt;
    Console.WriteLine(&amp;quot;myArrayList.IsFixedSize = &amp;quot; + myArrayList.IsFixedSize);&lt;br /&gt;
    Console.WriteLine(&amp;quot;myArrayList.IsReadOnly = &amp;quot; + myArrayList.IsReadOnly);&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;myArrayList.IsFixedSize = False&lt;br /&gt;
myArrayList.IsReadOnly = False&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Make an ArrayList Synchronized==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;using System;&lt;br /&gt;
using System.Collections;&lt;br /&gt;
class MainClass&lt;br /&gt;
{&lt;br /&gt;
  static void Main(string[] args)&lt;br /&gt;
  {&lt;br /&gt;
    ArrayList a = new ArrayList(10);&lt;br /&gt;
    ArrayList.Synchronized(a);&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Re-enumerate the list==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;using System; &lt;br /&gt;
using System.Collections; &lt;br /&gt;
 &lt;br /&gt;
class MainClass {  &lt;br /&gt;
  public static void Main() { &lt;br /&gt;
    ArrayList list = new ArrayList(1); &lt;br /&gt;
 &lt;br /&gt;
    for(int i=0; i &amp;lt; 10; i++) &lt;br /&gt;
      list.Add(i); &lt;br /&gt;
 &lt;br /&gt;
    IEnumerator etr = list.GetEnumerator(); &lt;br /&gt;
    while(etr.MoveNext())  &lt;br /&gt;
      Console.Write(etr.Current + &amp;quot; &amp;quot;); &lt;br /&gt;
 &lt;br /&gt;
    Console.WriteLine(); &lt;br /&gt;
 &lt;br /&gt;
     &lt;br /&gt;
    etr.Reset(); &lt;br /&gt;
    while(etr.MoveNext())  &lt;br /&gt;
      Console.Write(etr.Current + &amp;quot; &amp;quot;); &lt;br /&gt;
 &lt;br /&gt;
    Console.WriteLine(); &lt;br /&gt;
  } &lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;0 1 2 3 4 5 6 7 8 9&lt;br /&gt;
0 1 2 3 4 5 6 7 8 9&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Remove element 0, first &amp;quot;text&amp;quot; element, and two elements starting at index 3==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;using System;&lt;br /&gt;
using System.Collections;&lt;br /&gt;
class MainClass&lt;br /&gt;
{&lt;br /&gt;
  public static void Main()&lt;br /&gt;
  {&lt;br /&gt;
    ArrayList myArrayList = new ArrayList();&lt;br /&gt;
    myArrayList.Add(&amp;quot;A&amp;quot;);&lt;br /&gt;
    myArrayList.Add(&amp;quot;A&amp;quot;);&lt;br /&gt;
    myArrayList.Add(&amp;quot;A&amp;quot;);&lt;br /&gt;
    myArrayList.Add(&amp;quot;A&amp;quot;);&lt;br /&gt;
    myArrayList.Add(&amp;quot;A&amp;quot;);&lt;br /&gt;
    myArrayList.Add(&amp;quot;A&amp;quot;);&lt;br /&gt;
    myArrayList.Add(&amp;quot;A&amp;quot;);&lt;br /&gt;
    myArrayList.Add(&amp;quot;A&amp;quot;);&lt;br /&gt;
    myArrayList.Add(&amp;quot;A&amp;quot;);&lt;br /&gt;
    myArrayList.Add(&amp;quot;A&amp;quot;);&lt;br /&gt;
    &lt;br /&gt;
    string[] anotherStringArray = {&amp;quot;Here&amp;quot;s&amp;quot;, &amp;quot;some&amp;quot;, &amp;quot;more&amp;quot;, &amp;quot;text&amp;quot;};&lt;br /&gt;
    myArrayList.SetRange(0, anotherStringArray);&lt;br /&gt;
&lt;br /&gt;
    myArrayList.RemoveAt(0);&lt;br /&gt;
    myArrayList.Remove(&amp;quot;text&amp;quot;);&lt;br /&gt;
    myArrayList.RemoveRange(3, 2);&lt;br /&gt;
    DisplayArrayList(&amp;quot;myArrayList&amp;quot;, myArrayList);&lt;br /&gt;
  }&lt;br /&gt;
  public static void DisplayArrayList(string arrayListName, ArrayList myArrayList)&lt;br /&gt;
  {&lt;br /&gt;
    for (int i = 0; i &amp;lt; myArrayList.Count; i++){&lt;br /&gt;
      Console.WriteLine(arrayListName + &amp;quot;[&amp;quot; + i + &amp;quot;] = &amp;quot; +&lt;br /&gt;
        myArrayList[i]);&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Remove elements from ArrayList==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;using System; &lt;br /&gt;
using System.Collections; &lt;br /&gt;
 &lt;br /&gt;
class MainClass { &lt;br /&gt;
  public static void Main() { &lt;br /&gt;
    ArrayList al = new ArrayList(); &lt;br /&gt;
     &lt;br /&gt;
    Console.WriteLine(&amp;quot;Adding 6 elements&amp;quot;); &lt;br /&gt;
    // Add elements to the array list &lt;br /&gt;
    al.Add(&amp;quot;C&amp;quot;); &lt;br /&gt;
    al.Add(&amp;quot;A&amp;quot;); &lt;br /&gt;
    al.Add(&amp;quot;E&amp;quot;); &lt;br /&gt;
    al.Add(&amp;quot;B&amp;quot;); &lt;br /&gt;
    al.Add(&amp;quot;D&amp;quot;); &lt;br /&gt;
    al.Add(&amp;quot;F&amp;quot;); &lt;br /&gt;
 &lt;br /&gt;
    Console.WriteLine(&amp;quot;Removing 2 elements&amp;quot;); &lt;br /&gt;
    // Remove elements from the array list. &lt;br /&gt;
    al.Remove(&amp;quot;F&amp;quot;); &lt;br /&gt;
    al.Remove(&amp;quot;A&amp;quot;); &lt;br /&gt;
 &lt;br /&gt;
    Console.WriteLine(&amp;quot;Number of elements: &amp;quot; + &lt;br /&gt;
                       al.Count); &lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;Adding 6 elements&lt;br /&gt;
Removing 2 elements&lt;br /&gt;
Number of elements: 4&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Sort and search an ArrayList==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;using System; &lt;br /&gt;
using System.Collections; &lt;br /&gt;
 &lt;br /&gt;
class MainClass { &lt;br /&gt;
  public static void Main() { &lt;br /&gt;
    // create an array list &lt;br /&gt;
    ArrayList al = new ArrayList(); &lt;br /&gt;
     &lt;br /&gt;
    // Add elements to the array list &lt;br /&gt;
    al.Add(155); &lt;br /&gt;
    al.Add(413); &lt;br /&gt;
    al.Add(-41); &lt;br /&gt;
    al.Add(818); &lt;br /&gt;
    al.Add(31); &lt;br /&gt;
    al.Add(191); &lt;br /&gt;
 &lt;br /&gt;
    Console.Write(&amp;quot;Original contents: &amp;quot;); &lt;br /&gt;
    foreach(int i in al) &lt;br /&gt;
      Console.Write(i + &amp;quot; &amp;quot;); &lt;br /&gt;
    Console.WriteLine(&amp;quot;\n&amp;quot;); &lt;br /&gt;
 &lt;br /&gt;
    // Sort &lt;br /&gt;
    al.Sort(); &lt;br /&gt;
 &lt;br /&gt;
    // Use foreach loop to display the list. &lt;br /&gt;
    Console.Write(&amp;quot;Contents after sorting: &amp;quot;); &lt;br /&gt;
    foreach(int i in al) &lt;br /&gt;
      Console.Write(i + &amp;quot; &amp;quot;); &lt;br /&gt;
    Console.WriteLine(&amp;quot;\n&amp;quot;); &lt;br /&gt;
 &lt;br /&gt;
    Console.WriteLine(&amp;quot;Index of 413 is &amp;quot; + al.BinarySearch(413)); &lt;br /&gt;
  } &lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;Original contents: 155 413 -41 818 31 191&lt;br /&gt;
Contents after sorting: -41 31 155 191 413 818&lt;br /&gt;
Index of 413 is 4&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Use ArrayList copy constructor==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;using System;&lt;br /&gt;
using System.Collections;&lt;br /&gt;
class MainClass&lt;br /&gt;
{&lt;br /&gt;
  public static void Main()&lt;br /&gt;
  {&lt;br /&gt;
    ArrayList myArrayList = new ArrayList();&lt;br /&gt;
    myArrayList.Add(&amp;quot;This&amp;quot;);&lt;br /&gt;
    myArrayList.Add(&amp;quot;is&amp;quot;);&lt;br /&gt;
    myArrayList.Add(&amp;quot;a&amp;quot;);&lt;br /&gt;
    myArrayList.Add(&amp;quot;test&amp;quot;);&lt;br /&gt;
    ArrayList anotherArrayList = new ArrayList(myArrayList);&lt;br /&gt;
    Console.WriteLine(anotherArrayList);&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Use ArrayList.ToArray to create an object array from the contents of the collection==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;using System;&lt;br /&gt;
using System.Collections;&lt;br /&gt;
class MainClass&lt;br /&gt;
{&lt;br /&gt;
    public static void Main(string[] args)&lt;br /&gt;
    {&lt;br /&gt;
        // Create a new ArrayList and populate it.&lt;br /&gt;
        ArrayList list = new ArrayList(5);&lt;br /&gt;
        list.Add(&amp;quot;B&amp;quot;);&lt;br /&gt;
        list.Add(&amp;quot;G&amp;quot;);&lt;br /&gt;
        list.Add(&amp;quot;J&amp;quot;);&lt;br /&gt;
        list.Add(&amp;quot;S&amp;quot;);&lt;br /&gt;
        list.Add(&amp;quot;M&amp;quot;);&lt;br /&gt;
        object[] array2 = list.ToArray();&lt;br /&gt;
        Console.WriteLine(&amp;quot;Array 2:&amp;quot;);&lt;br /&gt;
        foreach (string s in array2) &lt;br /&gt;
        {&lt;br /&gt;
            Console.WriteLine(&amp;quot;\t{0}&amp;quot;, s);&lt;br /&gt;
        }&lt;br /&gt;
    &lt;br /&gt;
    }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;Array 2:&lt;br /&gt;
        B&lt;br /&gt;
        G&lt;br /&gt;
        J&lt;br /&gt;
        S&lt;br /&gt;
        M&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Use enumerator to access list==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;using System; &lt;br /&gt;
using System.Collections; &lt;br /&gt;
 &lt;br /&gt;
class MainClass {  &lt;br /&gt;
  public static void Main() { &lt;br /&gt;
    ArrayList list = new ArrayList(1); &lt;br /&gt;
 &lt;br /&gt;
    for(int i=0; i &amp;lt; 10; i++) &lt;br /&gt;
      list.Add(i); &lt;br /&gt;
 &lt;br /&gt;
    IEnumerator etr = list.GetEnumerator(); &lt;br /&gt;
    while(etr.MoveNext())  &lt;br /&gt;
      Console.Write(etr.Current + &amp;quot; &amp;quot;); &lt;br /&gt;
 &lt;br /&gt;
    Console.WriteLine(); &lt;br /&gt;
 &lt;br /&gt;
  } &lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;pre class=codeResult&amp;gt;0 1 2 3 4 5 6 7 8 9&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Use the Contains() method to determine if the string &amp;quot;text&amp;quot; is in the ArrayList==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;using System;&lt;br /&gt;
using System.Collections;&lt;br /&gt;
class MainClass&lt;br /&gt;
{&lt;br /&gt;
  public static void Main()&lt;br /&gt;
  {&lt;br /&gt;
    ArrayList myArrayList = new ArrayList();&lt;br /&gt;
    myArrayList.Add(&amp;quot;A&amp;quot;);&lt;br /&gt;
    myArrayList.Add(&amp;quot;A&amp;quot;);&lt;br /&gt;
    myArrayList.Add(&amp;quot;A&amp;quot;);&lt;br /&gt;
    myArrayList.Add(&amp;quot;A&amp;quot;);&lt;br /&gt;
    myArrayList.Add(&amp;quot;A&amp;quot;);&lt;br /&gt;
    myArrayList.Add(&amp;quot;A&amp;quot;);&lt;br /&gt;
    myArrayList.Add(&amp;quot;A&amp;quot;);&lt;br /&gt;
    myArrayList.Add(&amp;quot;A&amp;quot;);&lt;br /&gt;
    myArrayList.Add(&amp;quot;A&amp;quot;);&lt;br /&gt;
    myArrayList.Add(&amp;quot;A&amp;quot;);&lt;br /&gt;
    &lt;br /&gt;
    string[] anotherStringArray = {&amp;quot;Here&amp;quot;s&amp;quot;, &amp;quot;some&amp;quot;, &amp;quot;more&amp;quot;, &amp;quot;text&amp;quot;};&lt;br /&gt;
    myArrayList.SetRange(0, anotherStringArray);&lt;br /&gt;
&lt;br /&gt;
    if (myArrayList.Contains(&amp;quot;text&amp;quot;))&lt;br /&gt;
    {&lt;br /&gt;
      int index = myArrayList.IndexOf(&amp;quot;text&amp;quot;);&lt;br /&gt;
      Console.WriteLine(&amp;quot;myArrayList does contain the word &amp;quot;text&amp;quot;&amp;quot;);&lt;br /&gt;
      Console.WriteLine(&amp;quot;&amp;quot;text&amp;quot; first occurs at index &amp;quot; + index);&lt;br /&gt;
      index = myArrayList.LastIndexOf(&amp;quot;text&amp;quot;);&lt;br /&gt;
      Console.WriteLine(&amp;quot;&amp;quot;text&amp;quot; last occurs at index &amp;quot; + index);&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Use the IndexOf() and LastIndexOf() methods to display the first and last occurrence==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;using System;&lt;br /&gt;
using System.Collections;&lt;br /&gt;
class MainClass&lt;br /&gt;
{&lt;br /&gt;
  public static void Main()&lt;br /&gt;
  {&lt;br /&gt;
    ArrayList myArrayList = new ArrayList();&lt;br /&gt;
    myArrayList.Add(&amp;quot;A&amp;quot;);&lt;br /&gt;
    myArrayList.Add(&amp;quot;A&amp;quot;);&lt;br /&gt;
    myArrayList.Add(&amp;quot;A&amp;quot;);&lt;br /&gt;
    myArrayList.Add(&amp;quot;A&amp;quot;);&lt;br /&gt;
    myArrayList.Add(&amp;quot;A&amp;quot;);&lt;br /&gt;
    myArrayList.Add(&amp;quot;A&amp;quot;);&lt;br /&gt;
    myArrayList.Add(&amp;quot;A&amp;quot;);&lt;br /&gt;
    myArrayList.Add(&amp;quot;A&amp;quot;);&lt;br /&gt;
    myArrayList.Add(&amp;quot;A&amp;quot;);&lt;br /&gt;
    myArrayList.Add(&amp;quot;A&amp;quot;);&lt;br /&gt;
    &lt;br /&gt;
    string[] anotherStringArray = {&amp;quot;Here&amp;quot;s&amp;quot;, &amp;quot;some&amp;quot;, &amp;quot;more&amp;quot;, &amp;quot;text&amp;quot;};&lt;br /&gt;
    myArrayList.SetRange(0, anotherStringArray);&lt;br /&gt;
&lt;br /&gt;
    if (myArrayList.Contains(&amp;quot;text&amp;quot;))&lt;br /&gt;
    {&lt;br /&gt;
      int index = myArrayList.IndexOf(&amp;quot;text&amp;quot;);&lt;br /&gt;
      Console.WriteLine(&amp;quot;myArrayList does contain the word &amp;quot;text&amp;quot;&amp;quot;);&lt;br /&gt;
      Console.WriteLine(&amp;quot;&amp;quot;text&amp;quot; first occurs at index &amp;quot; + index);&lt;br /&gt;
      index = myArrayList.LastIndexOf(&amp;quot;text&amp;quot;);&lt;br /&gt;
      Console.WriteLine(&amp;quot;&amp;quot;text&amp;quot; last occurs at index &amp;quot; + index);&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Use the Reset() method and access the first row again using MoveNext()==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;using System;&lt;br /&gt;
using System.Collections;&lt;br /&gt;
class MainClass&lt;br /&gt;
{&lt;br /&gt;
  public static void Main()&lt;br /&gt;
  {&lt;br /&gt;
    ArrayList myArrayList = new ArrayList();&lt;br /&gt;
    myArrayList.Add(&amp;quot;A&amp;quot;);&lt;br /&gt;
    myArrayList.Add(&amp;quot;A&amp;quot;);&lt;br /&gt;
    myArrayList.Add(&amp;quot;A&amp;quot;);&lt;br /&gt;
    myArrayList.Add(&amp;quot;A&amp;quot;);&lt;br /&gt;
    myArrayList.Add(&amp;quot;A&amp;quot;);&lt;br /&gt;
    myArrayList.Add(&amp;quot;A&amp;quot;);&lt;br /&gt;
    myArrayList.Add(&amp;quot;A&amp;quot;);&lt;br /&gt;
    myArrayList.Add(&amp;quot;A&amp;quot;);&lt;br /&gt;
    myArrayList.Add(&amp;quot;A&amp;quot;);&lt;br /&gt;
    myArrayList.Add(&amp;quot;A&amp;quot;);&lt;br /&gt;
    &lt;br /&gt;
    string[] anotherStringArray = {&amp;quot;Here&amp;quot;s&amp;quot;, &amp;quot;some&amp;quot;, &amp;quot;more&amp;quot;, &amp;quot;text&amp;quot;};&lt;br /&gt;
    myArrayList.SetRange(0, anotherStringArray);&lt;br /&gt;
    Console.WriteLine(&amp;quot;Using the GetEnumerator() method to get an enumerator&amp;quot;);&lt;br /&gt;
    IEnumerator myEnumerator = myArrayList.GetEnumerator();&lt;br /&gt;
    while (myEnumerator.MoveNext())&lt;br /&gt;
    {&lt;br /&gt;
      Console.WriteLine(&amp;quot;myEnumerator.Current = &amp;quot; + myEnumerator.Current);&lt;br /&gt;
    }&lt;br /&gt;
    myEnumerator.Reset();&lt;br /&gt;
    myEnumerator.MoveNext();&lt;br /&gt;
    Console.WriteLine(&amp;quot;myEnumerator.Current = &amp;quot; + myEnumerator.Current);&lt;br /&gt;
    &lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Use the Reverse() method to reverse myArrayList==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;using System;&lt;br /&gt;
using System.Collections;&lt;br /&gt;
class MainClass&lt;br /&gt;
{&lt;br /&gt;
  public static void Main()&lt;br /&gt;
  {&lt;br /&gt;
    ArrayList myArrayList = new ArrayList();&lt;br /&gt;
    myArrayList.Add(&amp;quot;A&amp;quot;);&lt;br /&gt;
    myArrayList.Add(&amp;quot;A&amp;quot;);&lt;br /&gt;
    myArrayList.Add(&amp;quot;A&amp;quot;);&lt;br /&gt;
    myArrayList.Add(&amp;quot;A&amp;quot;);&lt;br /&gt;
    myArrayList.Add(&amp;quot;A&amp;quot;);&lt;br /&gt;
    myArrayList.Add(&amp;quot;A&amp;quot;);&lt;br /&gt;
    myArrayList.Add(&amp;quot;A&amp;quot;);&lt;br /&gt;
    myArrayList.Add(&amp;quot;A&amp;quot;);&lt;br /&gt;
    myArrayList.Add(&amp;quot;A&amp;quot;);&lt;br /&gt;
    myArrayList.Add(&amp;quot;A&amp;quot;);&lt;br /&gt;
    &lt;br /&gt;
    string[] anotherStringArray = {&amp;quot;Here&amp;quot;s&amp;quot;, &amp;quot;some&amp;quot;, &amp;quot;more&amp;quot;, &amp;quot;text&amp;quot;};&lt;br /&gt;
    myArrayList.SetRange(0, anotherStringArray);&lt;br /&gt;
    myArrayList.Reverse();&lt;br /&gt;
    DisplayArrayList(&amp;quot;myArrayList&amp;quot;, myArrayList);&lt;br /&gt;
  }&lt;br /&gt;
  public static void DisplayArrayList(string arrayListName, ArrayList myArrayList)&lt;br /&gt;
  {&lt;br /&gt;
    for (int i = 0; i &amp;lt; myArrayList.Count; i++){&lt;br /&gt;
      Console.WriteLine(arrayListName + &amp;quot;[&amp;quot; + i + &amp;quot;] = &amp;quot; +&lt;br /&gt;
        myArrayList[i]);&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Use the SetRange() method to copy the elements from anotherStringArray to myArrayList, starting at index 0==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;using System;&lt;br /&gt;
using System.Collections;&lt;br /&gt;
class MainClass&lt;br /&gt;
{&lt;br /&gt;
  public static void Main()&lt;br /&gt;
  {&lt;br /&gt;
    ArrayList myArrayList = new ArrayList();&lt;br /&gt;
    myArrayList.Add(&amp;quot;A&amp;quot;);&lt;br /&gt;
    myArrayList.Add(&amp;quot;A&amp;quot;);&lt;br /&gt;
    myArrayList.Add(&amp;quot;A&amp;quot;);&lt;br /&gt;
    myArrayList.Add(&amp;quot;A&amp;quot;);&lt;br /&gt;
    myArrayList.Add(&amp;quot;A&amp;quot;);&lt;br /&gt;
    myArrayList.Add(&amp;quot;A&amp;quot;);&lt;br /&gt;
    myArrayList.Add(&amp;quot;A&amp;quot;);&lt;br /&gt;
    myArrayList.Add(&amp;quot;A&amp;quot;);&lt;br /&gt;
    myArrayList.Add(&amp;quot;A&amp;quot;);&lt;br /&gt;
    myArrayList.Add(&amp;quot;A&amp;quot;);&lt;br /&gt;
    string[] anotherStringArray = {&amp;quot;Here&amp;quot;s&amp;quot;, &amp;quot;some&amp;quot;, &amp;quot;more&amp;quot;, &amp;quot;text&amp;quot;};&lt;br /&gt;
    myArrayList.SetRange(0, anotherStringArray);&lt;br /&gt;
&lt;br /&gt;
    DisplayArrayList(&amp;quot;myArrayList&amp;quot;, myArrayList);&lt;br /&gt;
  }&lt;br /&gt;
  public static void DisplayArrayList(string arrayListName, ArrayList myArrayList)&lt;br /&gt;
  {&lt;br /&gt;
    for (int i = 0; i &amp;lt; myArrayList.Count; i++){&lt;br /&gt;
      Console.WriteLine(arrayListName + &amp;quot;[&amp;quot; + i + &amp;quot;] = &amp;quot; +&lt;br /&gt;
        myArrayList[i]);&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  &lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Using the GetRange() method to get two elements from myArrayList, starting at index 1==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;using System;&lt;br /&gt;
using System.Collections;&lt;br /&gt;
class MainClass&lt;br /&gt;
{&lt;br /&gt;
  public static void Main()&lt;br /&gt;
  {&lt;br /&gt;
    ArrayList myArrayList = new ArrayList();&lt;br /&gt;
    myArrayList.Add(&amp;quot;A&amp;quot;);&lt;br /&gt;
    myArrayList.Add(&amp;quot;A&amp;quot;);&lt;br /&gt;
    myArrayList.Add(&amp;quot;A&amp;quot;);&lt;br /&gt;
    myArrayList.Add(&amp;quot;A&amp;quot;);&lt;br /&gt;
    myArrayList.Add(&amp;quot;A&amp;quot;);&lt;br /&gt;
    myArrayList.Add(&amp;quot;A&amp;quot;);&lt;br /&gt;
    myArrayList.Add(&amp;quot;A&amp;quot;);&lt;br /&gt;
    myArrayList.Add(&amp;quot;A&amp;quot;);&lt;br /&gt;
    myArrayList.Add(&amp;quot;A&amp;quot;);&lt;br /&gt;
    myArrayList.Add(&amp;quot;A&amp;quot;);&lt;br /&gt;
    &lt;br /&gt;
    string[] anotherStringArray = {&amp;quot;Here&amp;quot;s&amp;quot;, &amp;quot;some&amp;quot;, &amp;quot;more&amp;quot;, &amp;quot;text&amp;quot;};&lt;br /&gt;
    myArrayList.SetRange(0, anotherStringArray);&lt;br /&gt;
    ArrayList anotherArrayList = myArrayList.GetRange(1, 2);&lt;br /&gt;
    DisplayArrayList(&amp;quot;anotherArrayList&amp;quot;, anotherArrayList);&lt;br /&gt;
  }&lt;br /&gt;
  public static void DisplayArrayList(string arrayListName, ArrayList myArrayList)&lt;br /&gt;
  {&lt;br /&gt;
    for (int i = 0; i &amp;lt; myArrayList.Count; i++){&lt;br /&gt;
      Console.WriteLine(arrayListName + &amp;quot;[&amp;quot; + i + &amp;quot;] = &amp;quot; +&lt;br /&gt;
        myArrayList[i]);&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Using the TrimToSize() method to reduce the capacity of ArrayList==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;csharp&amp;quot;&amp;gt;using System;&lt;br /&gt;
using System.Collections;&lt;br /&gt;
class MainClass&lt;br /&gt;
{&lt;br /&gt;
  public static void Main()&lt;br /&gt;
  {&lt;br /&gt;
    ArrayList myArrayList = new ArrayList();&lt;br /&gt;
    myArrayList.Add(&amp;quot;A&amp;quot;);&lt;br /&gt;
    myArrayList.Add(&amp;quot;A&amp;quot;);&lt;br /&gt;
    myArrayList.Add(&amp;quot;A&amp;quot;);&lt;br /&gt;
    myArrayList.Add(&amp;quot;A&amp;quot;);&lt;br /&gt;
    myArrayList.Add(&amp;quot;A&amp;quot;);&lt;br /&gt;
    myArrayList.Add(&amp;quot;A&amp;quot;);&lt;br /&gt;
    myArrayList.Add(&amp;quot;A&amp;quot;);&lt;br /&gt;
    myArrayList.Add(&amp;quot;A&amp;quot;);&lt;br /&gt;
    myArrayList.Add(&amp;quot;A&amp;quot;);&lt;br /&gt;
    myArrayList.Add(&amp;quot;A&amp;quot;);&lt;br /&gt;
    &lt;br /&gt;
    string[] anotherStringArray = {&amp;quot;Here&amp;quot;s&amp;quot;, &amp;quot;some&amp;quot;, &amp;quot;more&amp;quot;, &amp;quot;text&amp;quot;};&lt;br /&gt;
    myArrayList.SetRange(0, anotherStringArray);&lt;br /&gt;
    myArrayList.TrimToSize();&lt;br /&gt;
    Console.WriteLine(&amp;quot;myArrayList.Capacity = &amp;quot; + myArrayList.Capacity);&lt;br /&gt;
  }&lt;br /&gt;
}&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	</feed>