Mega Code Archive

 
Categories / VB.Net Tutorial / Collections
 

Show and use the array boundaries

public class Test    public Shared Sub Main         Dim aryNames(9) As String         Dim intCounter As Integer         'Show the array boundaries.         Console.WriteLine("LOWER BOUND: " & aryNames.GetLowerBound(0))         Console.WriteLine("UPPER BOUND: " & aryNames.GetUpperBound(0))         Console.WriteLine("LENGTH: " & aryNames.Length)         'Populate the array.         For intCounter = 0 To aryNames.GetUpperBound(0)             aryNames(intCounter) = "Element position = " & intCounter         Next intCounter         'Show the elements of the array.         For intCounter = 0 To aryNames.GetUpperBound(0)             Console.WriteLine("Element position = " & intCounter)         Next intCounter    End Sub End class LOWER BOUND: 0 UPPER BOUND: 9 LENGTH: 10 Element position = 0 Element position = 1 Element position = 2 Element position = 3 Element position = 4 Element position = 5 Element position = 6 Element position = 7 Element position = 8 Element position = 9