Stack Class represents a simple last-in-first-out (LIFO) non-generic collection of objects. : Stack « Data Structure « VB.Net






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

1.Push Integer into a StackPush Integer into a Stack
2.Simple Demo for Stack: Push, Pop and PeekSimple Demo for Stack: Push, Pop and Peek
3.Stack to ArrayStack to Array
4.Stack Demo: push, pop and peekStack Demo: push, pop and peek
5.Stack<(Of <(T>)>) the ToArray method.