简体   繁体   English

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

[英]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.

相关问题 为面板中的每个文本框分配与数组C#不同的值 - for each textbox in panel assign a different value from an array c# 如何不可能为数组分配值,同时又不可能分别分配每个数组元素呢? - How to make it possible to assign value to an array, while making it Impossible to assign each of the array elements individually? 如何将String Array值分配给Collection或如何比较Array和LIst值 - How to Assign the String Array value to Collection or how to compare Array and LIst value 无法为集合分配新值 - Cannot Assign new value to Collection 给定一个包含字典中所有单词的数组,根据分配给字母表中每个字符的数值为每个单词分配一个值 - Given an array that is all words in the dictionary, assign a value to each word based on a numerical value assigned to each character in the alphabet 迭代收集,并使用OR运算符将其分配给单个属性 - Iterate Collection and Assign Each to Single Property with OR Operator 将字符串数组中的值分配给自定义类型数组的每个元素的字符串属性 - Assign a value from a string array to the string property of each element of a custom type array Linq 检查集合中的相等值并将值分配给其他集合 - Linq check value for equality in collection and assign value to other collection 在C#中为字典中的集合分配值 - Assign value to collection from dictionary in c# 如何将IEumerable Collection添加到队列并在.NET中异步处理每个项目? - How to add an IEumerable Collection to a Queue and Process each item asynchronously in .NET?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM