Example
using System; using System.Collections; namespace Samples { public class ICollectionSample { public static void Main() { ArrayList al = new ArrayList(); al.Add("damien"); al.Add("mark"); al.Add("brad"); Array a = Array.CreateInstance(typeof(string), al.Count); al.CopyTo(a, 0); Console.WriteLine("The contents of the array are:"); for(int i = 0; i < a.Length; i++) Console.WriteLine("{0} ",a.GetValue(i)); } } }
The contents of the array are: damien mark brad
Get .NET Framework Standard Library Annotated Reference, Volume 1: Base Class Library and Extended Numerics Library now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.