Using system;using system.collections.generic;using system.linq;using system.text;using System.Threading.Tasks; Namespace consoleapplication1{class Program {static void Main (string[] args) {//queue is characterized by first In-first-out queue<string> Queue = new queue<string> (); Queue. Enqueue ("Zhang San"); The queue adds the object to the end of the system.collections.generic.queue<t>. Queue. Enqueue ("John Doe"); Queue. Enqueue ("Harry"); int queuecount = queue. Count (); Returns the number of elements in a sequence, string name = Queue. Dequeue (); The team removed the elements from the first team and returned the removed elements. Console.WriteLine (name); Output "Zhang San" name = queue. Dequeue (); Because "Zhang San" has been removed. So now is "John Doe" is in the team first Console.WriteLine (name); Output "John Doe" name = queue. Dequeue (); Because "John Doe" is also removed, so there is only Harry left in the queue. Console.WriteLine (name); Output "Harry"//------------------------------------------------------------//stack is characterized by advanced back-out (understand the Yes, not much) stack<string&Gt stack = new stack<string> (); Stack. Push ("Zhang San"); into the stack, inserting the object into the top of the system.collections.generic.stack<t>. Stack. Push ("John Doe"); Stack. Push ("Harry"); int stackcount= stack. Count (); Returns the number of strings in the stack name1 = stack. Pop (); Out of the stack. Removes the element from the top of the stack and returns the removed element. Console.WriteLine (name); Output: "Harry" name1 = stack. Pop (); Console.WriteLine (name1);//output: "John Doe" name1 = stack. Pop (); Console.WriteLine (name1);//output: "Zhang San"//name1 = stack. Peek (); This is the object that returns the top of the stack, but does not remove the Console.readkey (); } }}
Queuing queue FIFO advanced first out stack stack filo advanced post-out