Stack Class represents a simple last-in-first-out (LIFO) non-generic collection of objects.
Imports System
Imports System.Collections
Imports Microsoft.VisualBasic
Public Class SamplesStack
Public Shared Sub Main()
Dim myStack As New Stack()
myStack.Push("Hello")
myStack.Push("World")
myStack.Push("!")
Console.WriteLine(myStack.Count)
PrintValues(myStack)
End Sub
Public Shared Sub PrintValues(myCollection As IEnumerable)
Dim obj As [Object]
For Each obj In myCollection
Console.Write(" {0}", obj)
Next obj
Console.WriteLine()
End Sub 'PrintValues
End Class
Related examples in the same category