Clone Dictionary - CSharp System.Collections.Generic

CSharp examples for System.Collections.Generic:IDictionary

Description

Clone Dictionary

Demo Code

/*This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
If a copy of the MPL was not distributed with this file, You can obtain one at
http://mozilla.org/MPL/2.0/./*from  ww  w .java 2s.  c  o  m*/

The Original Code is the TSOClient.

The Initial Developer of the Original Code is
ddfczm. All Rights Reserved.

Contributor(s): ______________________________________.
*/
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System;

public class Main{
        public static Dictionary<TKey, TValue> Clone<TKey, TValue>(Dictionary<TKey, TValue> input)
        {
            var result = new Dictionary<TKey, TValue>();
            foreach (var val in input)
            {
                result.Add(val.Key, val.Value);
            }
            return result;
        }
}

Related Tutorials