队列Queue,先进先出,先生产的货物先出货,后生产的货物后出货。

集合>队列Queue>创建队列

System.Collections.Queue类提供了四种重载构造函数。

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;

namespace ConsoleApplication1
{
    
class Program
    {
        
static void Main(string[] args)
        {
            
//使用默认构造函数构造Queue
            Queue qu = new Queue();
            qu.Enqueue(
"队列元素一");
            qu.Enqueue(
"队列元素二");
            qu.Enqueue(
null);
            
//使用实现了ICollection接口的类实例,此处是数组列表,构造Queue
            Queue qu2 = new Queue(new string[5] { "队列元素一""队列元素二""队列元素三""队列元素四""队列元素五" });
            
//使用初始容量为20个元素构造Queue.
            Queue qu3 = new Queue(20);
            
//使用初始容量为20个元素,等比因子为2来构造Queue.
            Queue qu4 = new Queue(202);
        }

    }

   
}

相关文章:

  • 2021-11-04
  • 2021-09-09
  • 2021-08-20
  • 2021-08-05
  • 2021-09-07
猜你喜欢
  • 2022-01-21
  • 2021-12-19
  • 2022-12-23
相关资源
相似解决方案