ArrayList in vb.net

I want to use  ArrayList  in vb.net please help me.
Last updated:12/23/2015 9:41:46 PM

1 Answers

Aditya Patel
Aditya Patel

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