Implement Priority Queue in C# from Scratch

This topic took my 2 days for understanding. I searched on whole internet for this but cant find the exact code for what i was searching. I needed a queue built from scratch so when i get it i decided to put it on my website so you guys don't waste time searching for it like me.

I have 2 solutions. First one is using one built in class but don’t worry, this is just to give you an understanding of priority queue. i understand & implement my own after understanding this one. so give it a try.

First Priority Queue Example Code:

Output

Second Priority Queue Example Code:

Output