Home »
VB.Net »
VB.Net Programs
VB.Net program to delete all items from Queue using the collection
By Nidhi Last Updated : November 11, 2024
Delete all items from Queue in VB.Net
Here, we will use the Clear() method of the Queue collection class to delete all items from the queue.
Program/Source Code:
The source code to delete all items from the Queue using collection is given below. The given program is compiled and executed successfully.
VB.Net code to delete all items from Queue
'VB.Net program to delete all items 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")
queue.Clear()
Console.WriteLine("All items are deleted from QUEUE successfully")
End Sub
End Module
Output
All items are deleted from QUEUE successfully
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 all the items from the queue using the Clear() method and printed the "All items are deleted from QUEUE successfully" message on the console screen.
VB.Net Data Structure Programs »