ArrayList in vb.net

Total Post:341

Points:2389
 1015  View(s)
Ratings:
Rate this:
I want to use  ArrayList  in vb.net please help me.
  1. Post:281

    Points:2003
    Re: ArrayList in vb.net

    It represents an ordered collection of an object that can be indexed individually. It is basically an alternative to an array. However, unlike array, you can add and remove items from a list at a specified position using an index and the array resizes itself automatically. It also allows dynamic memory allocation, adding, searching and sorting items in the list.

    Module Module1
        Sub Main()
            Dim list As ArrayList = New ArrayList()
            Dim i As Integer
            Console.WriteLine("Adding some numbers:")
            list.Add(45)
            list.Add(78)
            list.Add(33)
            list.Add(56)
            list.Add(12)
            list.Add(23)
            list.Add(9)
            Console.WriteLine("Capacity: {0} ", list.Capacity)
            Console.WriteLine("Total Count: {0}", list.Count)
            Console.Write("Record: ")
            For Each i In list
                Console.Write("{0} ", i)
            Next i
            Console.WriteLine()
            Console.Write("Sorted Record: ")
            list.Sort()
            For Each i In list
                Console.Write("{0} ", i)
            Next i
            Console.WriteLine()
            Console.ReadKey()
        End Sub
    End Module

Answer