Tutorial by Examples

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...
Dim aList as New List(Of Integer) aList.Add(1) aList.Add(10) aList.Add(1001) To add more than one item at a time use AddRange. Always adds to the end of the list Dim blist as New List(of Integer) blist.AddRange(alist) Dim aList as New List(of String) alist.AddRange({"one", &...
Dim aList As New List(Of String) aList.Add("Hello") aList.Add("Delete Me!") aList.Add("World") 'Remove the item from the list at index 1 aList.RemoveAt(1) 'Remove a range of items from a list, starting at index 0, for a count of 1) 'This will remove index 0, ...
Dim aList as New List(Of String) aList.Add("Hello, World") aList.Add("Test") Dim output As String = aList(0) output: Hello, World If you do not know the index of the item or only know part of the string then use the Find or FindAll method Dim aList as New List(Of S...
Dim aList as New List(Of String) aList.Add("one") aList.Add("two") aList.Add("three") For Each str As String in aList System.Console.WriteLine(str) Next Produces the following output: one two three Another option, would be to loop through using the ...
Sub Main() Dim People = New List(Of String)({"Bob Barker", "Ricky Bobby", "Jeff Bridges"}) Console.WriteLine(People.Contains("Rick James")) Console.WriteLine(People.Contains("Ricky Bobby")) Console.WriteLine(Pe...

Page 1 of 1