Click here to Skip to main content
15,890,557 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how to copy values from a dictionary to another on a button click?
Posted

Simplest way:
C#
Dictionary<mykeyclass,> d2 = d1.ToDictionary(k => k.Key, k => k.Value);
If you need to specify just some of the records, add a Where call in there before the ToDictionary.
 
Share this answer
 
Guess That you want work on individual objects not on references to the same object.


C#
Dictionary<string, string> A = new Dictionary<string, string>();
Dictionary<string, string> A1 = new Dictionary<string, string>(A);


if you want them references to the same object:

C#
Dictionary<string, string> A = new Dictionary<string, string>();
Dictionary<string, string> A1 = A;
 
Share this answer
 
v4

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900