0

我有一个队列集合

var queue = new Queue<ExchangeEmailInformation>(mailInformation);

其中包含两条记录。我也有 Guid 数组

public static List<Guid> FolderId { get; set; }

其中包含两个 guid 记录。我需要将这些 guid 重新分配给属性 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; }
   }
4

2 回答 2

0

而不是将值复制到列表中,您可以枚举队列并保留一个计数器

int i =0;
foreach (var email in queue)
{
    email.FolderId = this.FolderID[i];
    i++;
}
于 2012-12-26T08:57:29.080 回答
0
var currentQueue = queue.ToList();
                            for (int i = 0; i < currentQueue.Count; i++)
                            {
                                currentQueue[i].FolderId = FolderId[i];
                            }
于 2012-12-26T08:46:49.330 回答