ArrayList Learn programming Visual Basic (VB.net)



Lesson:

Dynamic Memory Management


Exercise:

ArrayList


Objetive:

Create a string list using the ArrayList class that already exists in the .NET platform.

Once created, display all the items stored in the list. Insert a new item in the second place of the list, and then display all the items again to check if the insertion was done correctly.


Code:

Imports System
Imports System.Collections
Namespace List
    Class Program
        Private Shared Sub Main(ByVal args As String())
            Dim miLista As ArrayList = New ArrayList()
            miLista.Add("Hola,")
            miLista.Add("soy")
            miLista.Add("yo")

            For Each frase As String In miLista
                Console.WriteLine(frase)
            Next

            miLista.Insert(1, "Como estas?")
        End Sub
    End Class
End Namespace



Juan A. Ripoll - Systems Tutorials and Programming Courses ©  All rights reserved.  Legal Conditions.