Lists can populated with any data type as necessary, with the format
Dim aList as New List(Of Type)
For example:
Create a new, empty list of Strings
Dim aList As New List(Of String)
Create a new list of strings, and populate with some data
VB.NET 2005/2008:
Dim aList as New List(Of String)(New String() {"one", "two", "three"})
VB.NET 2010:
Dim aList as New List(Of String) From {"one", "two", "three"}
--
VB.NET 2015:
Dim aList as New List(Of String)(New String() {"one", "two", "three"})
NOTE:
If you are receiving the following when the code is ran:
Object reference not set to an instance of an object.
Make sure you either declare as New
i.e. Dim aList as New List(Of String)
or if declaring without the New
, make sure you set the list to a new list - Dim aList as List(Of String) = New List(Of String)