[英]Assign each value of an array to a Queue Collection
I have an Queue Collection of 我有一个队列集合
var queue = new Queue<ExchangeEmailInformation>(mailInformation);
which contain two records. 其中包含两个记录。 I have also Guid array
我也有引导阵列
public static List<Guid> FolderId { get; set; }
which contain two guid records. 其中包含两个Guid记录。 I need to reassign these guids to Queue collection of property FolderId.How can I possible this?
我需要将这些向导重新分配到属性FolderId的Queue集合中。 Below are the ExchangeEmailInformation class
下面是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];
}
Rather than coping the values to a list you can just enumerate over the queue and keep a counter 与其将值对应到列表中,不如将其枚举整个队列并保留一个计数器
int i =0;
foreach (var email in queue)
{
email.FolderId = this.FolderID[i];
i++;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.