C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
So: At this point, we can add elements to our List collection dynamically, as with Add. This could not be done with the array.
VB.NET program that uses ToList Extension
Module Module1
Sub Main()
' Create array.
Dim array() As String = {"A", "B", "C", "D"}
' Create List.
Dim list As List(Of String) = array.ToList()
' Display Count.
Console.WriteLine(list.Count)
' Display each item.
For Each item As String In list
Console.WriteLine(" {0}", item)
Next
End Sub
End Module
Output
4
A
B
C
D
Statement that uses ToList: VB.NET
' Create List.
Dim list As List(Of String) = array.ToList()
Statement that uses List constructor: VB.NET
' Create List: same result.
Dim list As List(Of String) = New List(Of String)(array)