×

VB.Net Programs

VB.Net program to delete an item from QUEUE using the collection

By Nidhi Last Updated : November 11, 2024

Delete an item from a Queue in VB.Net

Here, we will use Dequeue() method of the Queue collection class to delete an item from the queue and print the deleted item on the console screen.

Program/Source Code:

The source code to delete an item from QUEUE using collection is given below. The given program is compiled and executed successfully.

VB.Net code to delete an item from a Queue

'VB.Net program to delete an item 
'from QUEUE using the collection.

Imports System
Imports System.Collections

Module Module1
    Sub Main()

        Dim queue As New Queue(5)

        queue.Enqueue("India")
        queue.Enqueue("USA")
        queue.Enqueue("UK")
        queue.Enqueue("CHINA")

        Console.WriteLine("Deleted item is: " & queue.Dequeue())
        Console.WriteLine("Deleted item is: " & queue.Dequeue())
        Console.WriteLine("Deleted item is: " & queue.Dequeue())
        Console.WriteLine("Deleted item is: " & queue.Dequeue())
    End Sub
End Module

Output

Deleted item is: India
Deleted item is: USA
Deleted item is: UK
Deleted item is: CHINA
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, And, we created an object of the Queue collection class for 5 elements. After that, we inserted 4 items using the Enqueue() method and then delete the items from the queue using the Dequeue() method and printed the deleted items on the console screen.

VB.Net Data Structure Programs »


Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.