ADVERTISEMENT
ADVERTISEMENT

VB.Net program to delete all items from Queue using the collection

Here, we are going to learn how to delete all items from Queue using the collection in VB.Net?
Submitted by Nidhi, on January 17, 2021

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 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 »

ADVERTISEMENT



ADVERTISEMENT



Comments and Discussions


ADVERTISEMENT

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.