Merge two IDictionary - CSharp System.Collections.Generic

CSharp examples for System.Collections.Generic:IDictionary

Description

Merge two IDictionary

Demo Code


using System.Collections.Generic;

public class Main{
        public static void Merge<TKey, TValue>(this IDictionary<TKey, TValue> target, IDictionary<TKey, TValue> source)
        {/*  ww w  .j a  v  a 2 s .c o m*/
            if (source == null) return;

            foreach (var kvp in source)
            {
                target.Add(kvp.Key, kvp.Value);
            }
        }
}

Related Tutorials