fcamuso

Collezioni - Queue e Stack

Oct 26th, 2021
904
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2. using System.Collections.Generic;
  3.  
  4. namespace Quee_Stack_Hashset_Dictionary
  5. {
  6.   class Program
  7.   {
  8.     static void Main(string[] args)
  9.     {
  10.       //Queue FIFO
  11.       Queue<string> coda = new Queue<string>();
  12.  
  13.       coda.Enqueue("Primo arrivato allo sportello");
  14.       coda.Enqueue("Secondo arrivato allo sportello");
  15.       coda.Enqueue("Terzo arrivato allo sportello");
  16.  
  17.       //foreach (string s in coda)
  18.       //  Console.WriteLine(s);
  19.  
  20.       //while (coda.TryDequeue( out string s))
  21.       //  Console.WriteLine(s);
  22.  
  23.       //while (coda.Count > 0)
  24.       //  Console.WriteLine(coda.Dequeue());
  25.  
  26.       Stack<string> pila = new Stack<string>();
  27.       pila.Push("Primo piatto");
  28.       pila.Push("Secondo piatto");
  29.       pila.Push("Terzo piatto");
  30.  
  31.       foreach (string s in pila)
  32.         Console.WriteLine(s);
  33.  
  34.       while (pila.Count > 0)
  35.         Console.WriteLine(pila.Pop());
  36.  
  37.     }
  38.   }
  39. }
  40.  
RAW Paste Data