fork(1) download
  1. using System;
  2. using System.Collections.Generic;
  3.  
  4. class Example
  5. {
  6. public static void Main()
  7. {
  8. Queue<string> bookCollection = new Queue<string>();
  9.  
  10. bookCollection.Enqueue ("The Black Book");
  11. bookCollection.Enqueue ("The Light we Cannot See");
  12. bookCollection.Enqueue ("The Sun is Also a Star");
  13. bookCollection.Enqueue ("A Man Called Ove");
  14. bookCollection.Enqueue ("A Dog's Purpose: A Novel for Humans");
  15.  
  16. // Print the breeds in my Queue
  17. Console.WriteLine("Here are some of the most popular books on New York Times best sellers list:");
  18. foreach (string books in bookCollection)
  19. {
  20. Console.WriteLine(books);
  21. }
  22. bookCollection.Dequeue ();
  23. bookCollection.Dequeue ();
  24.  
  25. Console.WriteLine("\nLets get rid of a couple and add some more.");
  26. foreach (string books in bookCollection)
  27. {
  28. Console.WriteLine(books);
  29. }
  30.  
  31.  
  32. Console.Write("\nNumber of books listed above: " + bookCollection.Count);
  33. }
  34. }
Success #stdin #stdout 0.01s 131648KB
stdin
Standard input is empty
stdout
Here are some of the most popular books on New York Times best sellers list:
The Black Book
The Light we Cannot See
The Sun is Also a Star
A Man Called Ove
A Dog's Purpose: A Novel for Humans

Lets get rid of a couple and add some more.
The Sun is Also a Star
A Man Called Ove
A Dog's Purpose: A Novel for Humans

Number of books listed above: 3