ArrayList.ToArray : ArrayList « System.Collections « C# / C Sharp by API






ArrayList.ToArray

  

using System;
using System.Collections;

class MainClass
{
    public static void Main(string[] args)
    {
        // Create a new ArrayList and populate it.
        ArrayList list = new ArrayList(5);
        list.Add("B");
        list.Add("G");
        list.Add("J");
        list.Add("S");
        list.Add("M");

        object[] array2 = list.ToArray();

        Console.WriteLine("Array 2:");
        foreach (string s in array2) 
        {
            Console.WriteLine("\t{0}", s);
        }
    
    }
}

   
    
  








Related examples in the same category

1.new ArrayList()
2.new ArrayList(Collection c)
3.ArrayList.Add
4.ArrayList.AddRange
5.ArrayList.BinarySearch
6.ArrayList.Capacity
7.ArrayList.Clear()
8.ArrayList.Clone
9.ArrayList.Contains
10.ArrayList.CopyTo
11.ArrayList.GetEnumerator()
12.ArrayList.GetRange
13.ArrayList.IndexOf
14.ArrayList.Insert
15.ArrayList.InsertRange()
16.ArrayList.IsFixedSize
17.ArrayList.IsReadOnly
18.ArrayList.LastIndexOf
19.ArrayList.Remove
20.ArrayList.RemoveAt
21.ArrayList.RemoveRange
22.ArrayList.Reverse()
23.ArrayList.SetRange
24.ArrayList.Sort()
25.ArrayList.Synchronized
26.ArrayList.ToArray(typeof(T))
27.ArrayList.TrimToSize()