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






ArrayList.CopyTo

  

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");

        
        string[] array1 = new string[list.Count];
        list.CopyTo(array1, 0);

        Console.WriteLine("Array 1:");
        foreach (string s in array1) 
        { 
            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.GetEnumerator()
11.ArrayList.GetRange
12.ArrayList.IndexOf
13.ArrayList.Insert
14.ArrayList.InsertRange()
15.ArrayList.IsFixedSize
16.ArrayList.IsReadOnly
17.ArrayList.LastIndexOf
18.ArrayList.Remove
19.ArrayList.RemoveAt
20.ArrayList.RemoveRange
21.ArrayList.Reverse()
22.ArrayList.SetRange
23.ArrayList.Sort()
24.ArrayList.Synchronized
25.ArrayList.ToArray
26.ArrayList.ToArray(typeof(T))
27.ArrayList.TrimToSize()