【发布时间】:2021-10-02 22:20:14
【问题描述】:
所以我正在编写一个 c# 控制台,它使用队列来显示一行人。代码如下:
customers.Enqueue("Jim");
customers.Enqueue("Bob");
customers.Enqueue("Susan");
customers.Enqueue("Liz");
customers.Enqueue("Mary");
Console.WriteLine("The number of the people in line at the bank is: ");
Console.WriteLine(customers.Count);
Console.WriteLine("The names of those in line at the bank are: " + customers.Peek());
customers.Enqueue("Andyn");
customers.Enqueue("Rhonda");
customers.Dequeue();
customers.Dequeue();
customers.Dequeue();
Console.WriteLine("The number of shoppers now in line is: " + customers.Count);
Console.WriteLine("The shopper currently first in line is: " + customers.Peek());
Console.ReadKey();
它运作良好,唯一的问题是当试图显示排队的人的名字时,它只显示吉姆。我想知道如何在行中显示其他人?谢谢。
【问题讨论】:
标签: c# visual-studio console