O'Reilly logo

.NET Common Language Runtime Unleashed by Kevin Burton

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

System.Collections

Many general-purpose collections are implemented in the .NET Framework SDK. Most of these collections are used as base classes to customize the feature set for an application.

System.Collections.ArrayList

Unlike the Array, an ArrayList can dynamically change its size as new items are added to the collection. Listing B.19 shows an example using an ArrayList (arraylist.cs).

Listing B.19. ArrayList Example
 static void Main(string [] args) { ArrayList al = new ArrayList(); lock(al.SyncRoot) { al.Add("This"); al.Add("is"); al.Add("a"); al.Add("test"); al.Add(0); al.Add(1); Console.WriteLine("Sychronized: {0} ", al.IsSynchronized); Console.WriteLine("Read-only: {0} ", al.IsReadOnly); Console.WriteLine("Fixed size: {0} ", al.IsFixedSize); ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required