Mega Code Archive

 
Categories / VB.Net Tutorial / Collections
 

Array GetLength, Array GetUpperBound

public class Test    public Shared Sub Main         Dim aryStatistics(14, 4) As Integer         Console.WriteLine("RANK: " & aryStatistics.Rank) 'Dimensions in array.         Console.WriteLine("TOTAL ELEMENTS: " & aryStatistics.Length) 'Total elements in array.         Console.WriteLine("ELEMENTS IN FIRST: " & aryStatistics.GetLength(0)) 'Elements in first dimension.         Console.WriteLine("ELEMENTS IN SECOND: " & aryStatistics.GetLength(1)) 'Elements in second dimension.         Console.WriteLine("LAST INDEX IN FIRST: " & aryStatistics.GetUpperBound(0)) 'Last index in the first dimension.         Console.WriteLine("LAST INDEX IN SECOND: " & aryStatistics.GetUpperBound(1)) 'Last index in the second dimension.    End Sub End class RANK: 2 TOTAL ELEMENTS: 75 ELEMENTS IN FIRST: 15 ELEMENTS IN SECOND: 5 LAST INDEX IN FIRST: 14 LAST INDEX IN SECOND: 4