Mega Code Archive

 
Categories / VB.Net / Data Structure
 

Array GetLength

Imports System Public Class SamplesArray     Public Shared Sub Main()         Dim MyArray1 As Array = Array.CreateInstance(GetType(Integer), 5)         Dim MyArray2 As Array = Array.CreateInstance(GetType(Integer), 5, 3, 2)         Dim myArray As Array = Array.CreateInstance(GetType(Array), 2)         myArray.SetValue(MyArray1, 0)         myArray.SetValue(MyArray2, 1)         Dim i As Integer = 0         Dim j As Integer         Dim rank As Integer         For Each anArray As Array In myArray             rank = anArray.Rank             If rank > 1                 For j = 0 To rank - 1                     Console.WriteLine("    Length of dimension({0:d}) = {1:d}", j, anArray.GetLength(j))                 Next j             End If             i = i + 1         Next anArray     End Sub End Class