ADVERTISEMENT

ADVERTISEMENT

ADVERTISEMENT

VB.Net program to pop or delete an item from the stack using the collection

Here, we are going to learn how to pop or delete an item from the stack using the collection in VB.Net?
Submitted by Nidhi, on January 15, 2021

Here, we will use the Pop() method of the Stack collection class to delete an item from the stack.

Program/Source Code:

The source code to pop or delete an item from the stack using collection is given below. The given program is compiled and executed successfully.

'VB.Net program to pop or delete an item from 
'the stack using the collection.

Imports System
Imports System.Collections

Module Module1
    Sub Main()
        Dim stk As New Stack(5)

        stk.Push(10)
        stk.Push(20)
        stk.Push(30)
        stk.Push(40)

        Console.WriteLine("Deleted item is: " & stk.Pop())
        Console.WriteLine("Deleted item is: " & stk.Pop())
        Console.WriteLine("Deleted item is: " & stk.Pop())
    End Sub
End Module

Output:

Deleted item is: 40
Deleted item is: 30
Deleted item is: 20
Press any key to continue . . .

Explanation:

In the above program, we created a module Module1 that contains the Main() function. The Main() function is the entry point for the program, Here, we created an object of Stack collection class for 5 elements. After that we inserted 4 items using the Push() method into the stack and then delete 3 items from the stack using the Pop() method of Stack collection class and printed the deleted item on the console screen.

VB.Net Data Structure Programs »

ADVERTISEMENT
ADVERTISEMENT




Comments and Discussions

ADVERTISEMENT

ADVERTISEMENT

ADVERTISEMENT

Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.