Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/317.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 将数组的每个值分配给队列集合_C#_.net - Fatal编程技术网

C# 将数组的每个值分配给队列集合

C# 将数组的每个值分配给队列集合,c#,.net,C#,.net,我有一个队列集合 var queue = new Queue<ExchangeEmailInformation>(mailInformation); var currentQueue=queue.ToList(); 对于(int i=0;i

我有一个队列集合

var queue = new Queue<ExchangeEmailInformation>(mailInformation);
var currentQueue=queue.ToList();
对于(int i=0;i
您只需在队列上枚举并保留计数器,而不是将值添加到列表中

int i =0;
foreach (var email in queue)
{
    email.FolderId = this.FolderID[i];
    i++;
}

在哪里分配了
列表文件夹ID
?定义和填充的
var queue
是同一类吗?您是否需要确保项目保留在队列中?将哪个guid分配给哪个ExchangeEmailInformation是否重要?例如,将FolderId[0]重新分配给属性FolderId的队列集合的第一条记录,将FolderId[1]重新分配给第二条记录,并在填充队列集合之前分配的列表。队列集合有两条记录。将Guid分配给队列时的问题是队列中的两个记录都包含相同的FolderId。
 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++;
}