public class Test
public Shared Sub Main
Dim aryDynArray() As Integer
Dim intResult As Integer
Dim intCounter As Integer
'Dimension the array at runtime.
intResult = 12
ReDim aryDynArray(intResult - 1)
Console.WriteLine("Array size is: " & aryDynArray.Length)
'Populate the array.
For intCounter = 0 To aryDynArray.GetUpperBound(0)
aryDynArray(intCounter) = intCounter + 100
Next intCounter
'Redimension the array and preserve its element values.
ReDim Preserve aryDynArray(aryDynArray.GetUpperBound(0) + 1)
Console.WriteLine("Array size is: " & aryDynArray.Length)
Console.WriteLine("First array value is: " & aryDynArray(0))
'Erase the array.
Erase aryDynArray
End Sub
End class
|