typestar

List(Of T) in Visual Basic

The growable collection: add, insert, remove, sort.

Dim guests As New List(Of String) From {"ada", "grace"}
guests.Add("alan")
guests.Insert(1, "edsger")
guests.Remove("grace")

Console.WriteLine(guests.Count)
Console.WriteLine(guests.Contains("ada"))

guests.Sort()
For Each name In guests
    Console.WriteLine(name)
Next

Console.WriteLine(String.Join(", ", guests))

How it works

  1. New List(Of String) From {...} seeds the list at construction.
  2. Insert places by position; Remove deletes by value.
  3. Sort orders in place; String.Join prints it in one line.

Keywords and builtins used here

The run, in numbers

Lines
14
Characters to type
313
Tokens
98
Three-star pace
90 tpm

At the three-star pace of 90 tokens a minute, this run takes about 65 seconds.

Type this snippet

Step 2 of 3 in Collections, step 5 of 29 in Language basics.

← Previous Next →