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.  
  10. class StackSample
  11. {
  12.  
  13. static void Main(string[] args)
  14. {
  15. // Creates stack for strings.
  16. Stack operaStack = new Stack();
  17.  
  18. // Adds operas to the stack.
  19. operaStack.Push ("Don Giovanni");
  20. operaStack.Push ("Un Ballo in Maschera");
  21. operaStack.Push ("Aida");
  22. operaStack.Push ("Der fliegende Hollander");
  23. operaStack.Push ("Gotterdammerung");
  24. operaStack.Push ("Turandot");
  25.  
  26. Console.WriteLine("A list of favorite operas ...");
  27.  
  28. // Print all favorite operas.
  29. foreach(string opera in operaStack) {
  30. Console.WriteLine(opera);
  31. } // foreach
  32.  
  33. } // main
  34.  
  35. } // class StackSample
  36.  
Success #stdin #stdout 0.05s 28712KB
stdin
Standard input is empty
stdout
A list of favorite operas ...
Turandot
Gotterdammerung
Der fliegende Hollander
Aida
Un Ballo in Maschera
Don Giovanni