fork download
  1. using System;
  2. using System.Collections.Generic;
  3.  
  4. class QueueSample
  5. {
  6. public static void Main()
  7. {
  8. Queue<string> surfbreakCollection = new Queue<string> ();
  9.  
  10. surfbreakCollection.Enqueue ("Mavericks");
  11. surfbreakCollection.Enqueue ("Teahupoo");
  12. surfbreakCollection.Enqueue ("Jaws");
  13. surfbreakCollection.Enqueue ("Nazare");
  14. surfbreakCollection.Enqueue ("Cocoa Beach");
  15.  
  16. // Print the movies in my Queue
  17. Console.WriteLine("Here are the current favorite surf break Queue");
  18. foreach (string breaks in surfbreakCollection)
  19. {
  20. Console.WriteLine(breaks);
  21. }
  22.  
  23. // I just finished watching Iron Man 2 ... just send it back
  24. // When NetFlix gets it, they will remove Iron Man 2 from my Queue
  25. // Note that Iron Man was at the top of the Queue, so it deletes it
  26. surfbreakCollection.Dequeue ();
  27.  
  28. // and my new Queue will look like this
  29.  
  30. Console.WriteLine("\nMy surf break queue after removing Marericks");
  31. foreach (string breaks in surfbreakCollection)
  32. {
  33. Console.WriteLine(breaks);
  34. }
  35.  
  36. // Print number of current movies in my NetFlix Queue
  37. Console.Write("\nNumber of surf breaks in the surf break Queue: " + surfbreakCollection.Count);
  38. }
  39. }
Success #stdin #stdout 0.03s 27532KB
stdin
Standard input is empty
stdout
Here are the current favorite surf break Queue
Mavericks
Teahupoo
Jaws
Nazare
Cocoa Beach

My surf break queue after removing Marericks
Teahupoo
Jaws
Nazare
Cocoa Beach

Number of surf breaks in the surf break Queue: 4