var queue = new Queue<ExchangeEmailInformation>(newMails);
如何将上述队列转换为List
。
答案 0 :(得分:16)
答案 1 :(得分:4)
由于Queue<T> Class实现IEnumerable<T>而List<T> Class有constructor that accepts an IEnumerable<T>,您只需将队列传递给该构造函数即可:
var result = new List<ExchangeEmailInformation>(queue);
答案 2 :(得分:-1)
Try this... simple
System.Collections.Queue q = new System.Collections.Queue(4);
q.Enqueue("hai"); q.Enqueue("how"); q.Enqueue("are"); q.Enqueue("u");
int count = q.Count;
List<string> list = new List<string>();
for(int i =0; i < count; i++)
{
list.Add(q.Dequeue().ToString());
}