<< 常用网站开发类Firefox扩展插件 C#静态变量 >>

 Question

 

How do i concat two dictionaries aka the following sample:
Dictionary<int, string> a;
Dictionary<int, string> b;
b.Add(a);

Answer

foreach (KeyValuePair<int,string> pair in b)
{
a.Add(pair.Key, pair.Value);
}
Or if you're using .NET 3.5 you could consider creating a new
dictionary instead, using something like:
var combined = a.Concat(b)
.ToDictionary(pair => pair.Key, pair => pair.Value);

Add comment

  Country flag

biuquote
Loading

赞助商链接

©2009 - 2011 Themes by redfox66.com Powered by BlogEngine.NET ver:2.5.0.8 Log in
无觅相关文章插件,快速提升流量