VKinfotek Inc.
  • Us
    About Us
    Contact Us
  • FAQs
  • Ready Software
    Ready ERP ASP Core Software for Azure Cloud
    Ready Web ERP Software
    Ready ASP.Net Azure Software
    Ready C# SQL Server Accounting Software
    Ready ASP.Net MVC and EF Software
First slide
Earn $100/hour in USA! Click Here

retrieve arraylist items using enumerators

ArrayList allows us to use Enumerators to access the collection elements. This is possible because the ArrayList class implements IEnumerable interface. The GetEnumerator method of IEnumerable interface returns Enumerator object for the entire ArrayList. Using Enumerators, we can read the data in the collection, but we cannot modify the underlying collection.



At the beginning, the enumerator is positioned before the first element in the collection and to access the first element, we have to use MoveNext() method to advance and read the value of the first element. When the enumerator is positioned after the last element in the collection, the MoveNext method returns false and the While Loop exits.

private void Form1_Load(object sender, EventArgs e)
{
	ArrayList arrayList = new ArrayList();
	arrayList.Add("Customer1");
	arrayList.Add("Customer2");
	arrayList.Add("Customer3");
	arrayList.Add("Customer4");
	arrayList.Add("Customer5");
	
    //Iterating through items - Using Enumerators
	IEnumerator enumerator = arrayList.GetEnumerator();
	while (enumerator.MoveNext())
	{
		str += enumerator.Current.ToString() + "\n";
	}
	MessageBox.Show(str);


ArrayList Articles
  • Arrays vs ArrayList
  • how to create and add items into the ArrayList in csharp
  • how to add items to the arraylist using an add method
  • retrieve arraylist items using for each loop
  • retrieve arraylist items using indexers
  • insert items to the arraylist using insert and insertrange method
  • remove items from arraylist
  • find item in arraylist using indexof method
  • bind arraylist with gridview control in asp net application
  • how to bind arraylist with dropdownlist in asp net application
  • how to bind arraylist with radiobuttonlist in asp.net application
  • convert arraylist to string array
  • convert string array to arraylist
  • convert datatable into an arraylist
  • convert dataset to arraylist in asp.net using c#
  • how to retrieve arraylist items in reverse order
  • difference between arraylist and list collection
Most Viewed

Azure Q & A
Azure Platform
Grid-View
GridView CommandField example
Details-View
GridView and DetailsView Master/Detail page using SqlDataSource control
POCO
POCO overview and advantages - POCO class, Entity Framework in Enterprise Applications
Entity Framework
Query entity data model using linq to entities
Array List
Difference between arraylist and list collection
Web Services
How to create a Web service using Visual Studio.net
Form-View
FormView DataBound Event
Object Oriented Programming
Calling base class constructor in C#
Linq
Convert a sequence to a generic list using ToList()method
Project Ideas
Project ideas for students
AccountingSoftware
Accounting Software
MVC
Creating an ASP.Net MVC 3 application
.Net
Using assemblies in .net applications
ASP .Net
How to implement form validation using ASP.Net 2.0 Validation Controls

  • SITEMAP
  • Terms of use
  • Testimonials

Back to top

Copyright © 2016 - All Rights Reserved - VKInfotek.com