Visual Basic Adding Elements to List
In Visual Basic, it is necessary to use the Add() method to add an element to the List.
In order to use the List object, you need to add the System.Collections.Generic namespace to your project.
Let's examine the example below..
Module ModuleTest Sub Main() Dim cityList = New List(Of String)() cityList.Add("Rome") cityList.Add("Berlin") cityList.Add("London") cityList.Add("Madrid") Console.WriteLine("Cities..." & vbLf) For Each city In cityList Console.WriteLine(city) Next Console.ReadLine() End Sub End ModuleWe created a List object named cityList and added 4 elements and printed it on the screen.