Copies all the elements of IDictionary to target IDictionary. - CSharp System.Collections

CSharp examples for System.Collections:IDictionary

Description

Copies all the elements of IDictionary to target IDictionary.

Demo Code


using System.IO;/*from  w  w  w  . ja va 2 s  .  c  o  m*/
using System;

public class Main{
        /// <summary>
        /// Copies all the elements of d to target.
        /// </summary>
        /// <param name="target">Collection where d elements will be copied.</param>
        /// <param name="d">Elements to copy to the target collection.</param>
        public static void PutAll(System.Collections.IDictionary target, System.Collections.IDictionary d)
        {
            if (d != null)
            {
                System.Collections.ArrayList keys = new System.Collections.ArrayList(d.Keys);
                System.Collections.ArrayList values = new System.Collections.ArrayList(d.Values);

                for (int i = 0; i < keys.Count; i++)
                    target[keys[i]] = values[i];
            }
        }
}

Related Tutorials