Home > DeveloperSection > Forums > ArrayList in vb.net
Ankit Singh

Total Post:341

Points:2389
Posted on    December-23-2015 9:39 PM

 VB.Net VB.Net  Array List 
Ratings:


 1 Reply(s)
 225  View(s)
Rate this:
I want to use  ArrayList  in vb.net please help me.


aditya kumar Patel

Total Post:242

Points:1722
Posted on    December-23-2015 9:41 PM

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


Don't want to miss updates? Please click the below button!

Follow MindStick