private static void CustomerServiceQueue() { Queue CSQ = new Queue(); CSQ.Enqueue("Gautam"); CSQ.Enqueue("Nargis"); CSQ.Enqueue("Beth"); CSQ.Enqueue("Slobodan"); Console.WriteLine("Peeking Queue: {0}", CSQ.Peek()); Console.WriteLine("Check if CSQ Contains Beth : {0}", CSQ.Contains("Beth")); while (CSQ.Count > 0) { Console.WriteLine(CSQ.Dequeue()); } }
Contains checks for presence of the given object in the queue. Peek returns the first element from the queue
Dequeuue does the same as Peek, however, it also removes the object
No comments:
Post a Comment