Click here to Skip to main content
15,896,444 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
how to display a data from arraylist in c# .net......
Posted
Updated 2-Jun-16 7:36am

This link may help you

ArrayList[^]
Use ArrayList[^]
 
Share this answer
 
The following code example shows how to create and initialize an ArrayList [^]and how to print out its values"

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

   public static void Main()  {

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

      // Displays the properties and values of the ArrayList.
      Console.WriteLine( "myAL" );
      Console.WriteLine( "    Count:    {0}", myAL.Count );
      Console.WriteLine( "    Capacity: {0}", myAL.Capacity );
      Console.Write( "    Values:" );
      PrintValues( myAL );
   }

   public static void PrintValues( IEnumerable myList )  {
      foreach ( Object obj in myList )
         Console.Write( "   {0}", obj );
      Console.WriteLine();
   }

}


/* 
This code produces output similar to the following:

myAL
    Count:    3
    Capacity: 4
    Values:   Hello   World   !

*/


Also refer:
How to use C# ArrayList Class[^]
 
Share this answer
 
You can try something like

C#
ArrayList arr = new ArrayList();

for (int iIndex = 0; iIndex < arr.Count; iIndex++)
{
    object o = arr[iIndex];
}

But I would rather go with

List Class[^] and List.Count Property[^]
 
Share this answer
 
Comments
Prasad_Kulkarni 19-Jul-12 4:49am    
My 5!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900