将数组的每个值分配给队列集合
本文关键字:分配 队列 集合 数组 | 更新日期: 2023-09-27 17:49:36
我有一个队列集合
var queue = new Queue<ExchangeEmailInformation>(mailInformation);
包含两条记录。还有Guid array
public static List<Guid> FolderId { get; set; }
包含两个向导记录。我需要把这些guids重新分配给Queue collection的属性FolderId。我怎么可能做到呢?下面是ExchangeEmailInformation类
public class ExchangeEmailInformation:IEmailInformation
{
public string Subject { get; set; }
public string Sender { get; set; }
public AttachmentCollection Attachment { get; set; }
public Guid FolderId { get; set; }
}
var currentQueue = queue.ToList();
for (int i = 0; i < currentQueue.Count; i++)
{
currentQueue[i].FolderId = FolderId[i];
}
与其将值复制到列表中,不如在队列中枚举并保留计数器
int i =0;
foreach (var email in queue)
{
email.FolderId = this.FolderID[i];
i++;
}