using a for loop to iterate through a dictionary

后端 未结 3 1644
陌清茗
陌清茗 2020-12-16 09:53

I generally use a foreach loop to iterate through Dictionary.

Dictionary dictSummary = new Dictionary();
<         


        
3条回答
  •  温柔的废话
    2020-12-16 10:02

    You don't need to use .ToArray() or .ElementAt(). It is as simple as accessing the dictionary with the key:

    dictSummary.Keys.ToList().ForEach(k => dictSummary[k] = dictSummary[k].Trim());
    

提交回复
热议问题