ArrayList:
• ArrayList implements IList interface
• Size can be increased dynamically as required
• Not guaranteed to be sorted
• Default initial capacity is 0, as elements are added, capacity is increased through reallocation
• Capacity can be decreased through TrimToSize or setting Capacity property
• To guarantee ThreadSafety of the ArrayList, all operations must be done through the wrapper returned by the Synchronized method
Code Listing:ArrayList
ArrayList myAL = new ArrayList();
myAL.Add(“Hello”);
myAL.Add(“World”);
myAL.Add(“!!!”);
Console.WriteLine(myAL.Count);
Console.WriteLine(myAL.Capacity);
PrintValues(myAL);
public static void PrintValues(IEnumerable myList )
{
foreach(Object obj in mylist)
Console.Write(obj);
Console.WriteLine();
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment