Collection Examples

Collection Stack Example

Imports System
Imports System.Collections.Generic
Imports System.Collections
Imports System.ComponentModel
Imports System.Data
Imports System.Drawing
Imports System.Linq
Imports System.Text
Imports System.Windows.Forms

Namespace CollectionStackExample1
    Public Partial Class Form1
        Inherits Form

        Public Sub New()
            InitializeComponent()
        End Sub

        Private Sub button1_Click(ByVal sender As Object, ByVal e As EventArgs)
            Dim days As Stack = New Stack()
            days.Push("SunDay")
            days.Push("MonDay")
            days.Push("TueDay")
            days.Push("WedDay")
            days.Push("ThuDay")
            days.Push("FriDay")
            days.Push("SaturDay")

            If days.Count = 7 Then
                MessageBox.Show(days.Pop().ToString())
            Else
                MessageBox.Show("SaturDay does not exist")
            End If
        End Sub
    End Class
End Namespace


©Copyright 2016 All Rights Reserved LearnDotNetHome.com