How to combin 2 dictionary object to single one:

How to combin 2 dictionary object to single one:

 

using System.Linq;
using System.Linq.Expressions;

 

 Dictionary<string, object> d1 = new Dictionary<string, object>();
            d1.Add("a", new object());
            d1.Add("b", new object());
            Dictionary<string, object> d2 = new Dictionary<string, object>();
            d2.Add("c", new object());
            d2.Add("d", new object());

            Dictionary<string, object> d3 = d1.Concat(d2).ToDictionary(e => e.Key, e => e.Value);

            foreach (var item in d3)
            {
                Console.WriteLine(item.Key);
            }

 

 

About Lambda: http://msdn.microsoft.com/zh-cn/library/bb397687.aspx

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章