Loop through an Array : For Each « Language Basics « VB.Net

Loop through an Array

Loop through an Array
Imports System

Public Class MainClass
    Shared Sub Main()
        'Declare an array
        Dim strFriends(4) As String

        'Populate the array
        strFriends(0) = "R"
        strFriends(1) = "B"
        strFriends(2) = "S"
        strFriends(3) = "S"
        strFriends(4) = "K"

        'Enumerate the array
        For Each strName As String In strFriends
            'Add the array item to the list

    End Sub
End Class


Related examples in the same category

1.Exit a For Each loopExit a For Each loop
2.Use For Each to Loop an ArrayUse For Each to Loop an Array