Array List


ArrayList is one of the collections in .Net which implements the IList interface; it has more advantages than traditional array.
  • . ArrayList size is increased dynamically whenever new item is added
  • . If required, Array can be resized using TrimToSize method or by changing Capacity property
  • . It is capable to store anything as an item
  • . Array items can be accessed using an Integer Index
  • . It has more properties and methods than normal Array

Let us see how to create an ArrayList instance using DotNetFactory and sort the elements in an ArrayList using the Sort method.

Code


Synopsis

On running the above code, the three items will be added to the ArrayList and gets sorted. We are just getting the 1st element in the ArrayList after sorting as the output i.e. oArrayList(0). Here the index starts with 0. Before sorting, the 1st item in the ArrayList will be “Paris”. Once the array is sorted, “London” will be the 1st item in the ArrayList and will be displayed as the output.

Leave a Reply

Your email address will not be published. Required fields are marked *