asp.net.ph

ArrayList Class

System.Collections Namespace


Implements the IList interface using an array whose size is dynamically increased as required.

ArrayList Class Members

Collapse   Constructors

Visibility Constructor Parameters
public ArrayList ( )
public ArrayList ( Int32 capacity )
public ArrayList ( ICollection c )

Collapse   Properties

Visibility Name Value Type Accessibility
public Capacity Int32 [ Get , Set ]
public Count Int32 [ Get ]
public IsFixedSize Boolean [ Get ]
public IsReadOnly Boolean [ Get ]
public IsSynchronized Boolean [ Get ]
public Item ( Int32 index ) Object [ Get , Set ]
public SyncRoot Object [ Get ]

Collapse   Methods

Visibility Name Parameters Return Type
public static Adapter ( IList list ) ArrayList
public Add ( Object value ) Int32
public AddRange ( ICollection c ) Void
public BinarySearch ( Object value , IComparer comparer ) Int32
public BinarySearch ( Object value ) Int32
public BinarySearch ( Int32 index , Int32 count , Object value , IComparer comparer ) Int32
public Clear ( ) Void
public Clone ( ) Object
public Contains ( Object item ) Boolean
public CopyTo ( Int32 index , Array array , Int32 arrayIndex , Int32 count ) Void
public CopyTo ( Array array , Int32 arrayIndex ) Void
public CopyTo ( Array array ) Void
public static FixedSize ( ArrayList list ) ArrayList
public static FixedSize ( IList list ) IList
public GetEnumerator ( Int32 index , Int32 count ) IEnumerator
public GetEnumerator ( ) IEnumerator
public GetRange ( Int32 index , Int32 count ) ArrayList
public IndexOf ( Object value , Int32 startIndex ) Int32
public IndexOf ( Object value , Int32 startIndex , Int32 count ) Int32
public IndexOf ( Object value ) Int32
public Insert ( Int32 index , Object value ) Void
public InsertRange ( Int32 index , ICollection c ) Void
public LastIndexOf ( Object value ) Int32
public LastIndexOf ( Object value , Int32 startIndex , Int32 count ) Int32
public LastIndexOf ( Object value , Int32 startIndex ) Int32
public static ReadOnly ( ArrayList list ) ArrayList
public static ReadOnly ( IList list ) IList
public Remove ( Object obj ) Void
public RemoveAt ( Int32 index ) Void
public RemoveRange ( Int32 index , Int32 count ) Void
public static Repeat ( Object value , Int32 count ) ArrayList
public Reverse ( Int32 index , Int32 count ) Void
public Reverse ( ) Void
public SetRange ( Int32 index , ICollection c ) Void
public Sort ( Int32 index , Int32 count , IComparer comparer ) Void
public Sort ( IComparer comparer ) Void
public Sort ( ) Void
public static Synchronized ( ArrayList list ) ArrayList
public static Synchronized ( IList list ) IList
public ToArray ( Type type ) Array
public ToArray ( ) Object
public TrimToSize ( ) Void

Remarks

The capacity of an ArrayList is the number of elements the list can hold. As elements are added to an ArrayList, the capacity is automatically increased as required through reallocation. The capacity can be decreased by calling TrimToSize or by setting the Capacity property explicitly.

Indexes in this collection are zero-based.

Example

The following example shows how to create and initialize an ArrayList and how to print out its values.

using System;
using System.Collections;
public class SamplesArrayList  {

   public static void Main()  {

      // Creates and initializes a new ArrayList.
      ArrayList myArrayList = new ArrayList();
      myArrayList.Add ("Hello");
      myArrayList.Add ("World");
      myArrayList.Add ("!");

      // Displays the properties and values of the ArrayList.
      Response.Write ("myArrayList" + "<br>");
      Response.Write ("Count: " + myArrayList.Count + "<br>");
      Response.Write ("Capacity: " + myArrayList.Capacity + "<br>");
      Response.Write ("Values:" + "<br>");
      PrintValues ( myArrayList );
   }

   public static void PrintValues ( IEnumerable myList )  {
      System.Collections.IEnumerator myEnumerator = myList.GetEnumerator();

      while ( myEnumerator.MoveNext() ) {
         Response.Write (myEnumerator.Current + "<br>");
      }
      Response.Write ("<br>");
   }
}
  C# VB
Skip Navigation Links



Home
Suggested Reading


Previous page Back to top Next page

© 2000-2010 Rey Nuñez All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note

You can help support asp.net.ph