VB.Net program to copy stack elements into an array using the collection
'VB.Net program to copy stack elements into
'an array using the collection.
Imports System
Imports System.Collections
Module Module1
Sub Main()
Dim stk As New Stack(5)
Dim arr(4) As Integer
stk.Push(40)
stk.Push(30)
stk.Push(20)
stk.Push(10)
stk.CopyTo(arr, 0)
Console.WriteLine("Array elements are:")
For i = 0 To 3 Step 1
Console.WriteLine(vbTab & "Item[" & (i + 1) & "]: " & arr(i))
Next
End Sub
End Module
Array elements are:
Item[1]: 10
Item[2]: 20
Item[3]: 30
Item[4]: 40
Press any key to continue . . .
Table of Contents