fork download
  1. // Naomi Jones
  2. // Survey, Summer 2025
  3. // July 6, 2025
  4. // Assignment 6 - 3 C# Stacks
  5.  
  6. using System;
  7. using System.Collections.Generic;
  8. using System.Collections;
  9. class StackSample
  10. {
  11.  
  12. static void Main(string[] args)
  13. {
  14. Stack operaStack = new Stack();
  15. operaStack.Push ("Don Giovanni");
  16. operaStack.Push ("Un Ballo in Maschera");
  17. operaStack.Push ("Aida");
  18. operaStack.Push ("Der fliegende Holländer");
  19. operaStack.Push ("Werther");
  20. operaStack.Push ("Turandot");
  21.  
  22.  
  23. Console.WriteLine("A list of favorite operas ...");
  24.  
  25. // Print all favorite operas.
  26. foreach(string opera in operaStack) {
  27. Console.WriteLine(opera);
  28. } // foreach
  29.  
  30. } // main
  31.  
  32. } // class Stack Sample
Success #stdin #stdout 0.05s 26660KB
stdin
Standard input is empty
stdout
A list of favorite operas ...
Turandot
Werther
Der fliegende Holländer
Aida
Un Ballo in Maschera
Don Giovanni