我如何将队列出列队列

时间:2014-04-23 10:06:36

标签: c# queue

假设

Queue<String> aQueue =new Queue<string>();
Customer aCustomer=new Customer();

我使用aCustomeraCustomer排入队列。(多个值)

我如何取消aCustomer并将这些值放入aCustomer。(多个变量)。

如果有人有解决方案,请帮助我。

2 个答案:

答案 0 :(得分:2)

您可以使用EnqueueDequeue

Queue<Customer> aQueue =new Queue<Customer>();
Customer aCustomer=new Customer();

aQueue.Enqueue(aCustomer);
aCustomer = aQueue.Dequeue();

答案 1 :(得分:0)

你在找这样的东西吗?

Queue<Customer> aQueue = new Queue<Customer>();
Customer customer = new Customer { Name = "Test" };
aQueue.Enqueue(customer);
customer = new Customer { Name = "Test1" };
aQueue.Enqueue(customer);
customer = new Customer { Name = "Test2" };
aQueue.Enqueue(customer);

while (aQueue.Any())
{
    customer = aQueue.Dequeue();
    // use customer
}