如何在单击按钮时将值从字典复制到另一个字典? [英] how to copy values from a dictionary to another on a button click?

查看:89
本文介绍了如何在单击按钮时将值从字典复制到另一个字典?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在单击按钮时将值从字典复制到另一个字典?

how to copy values from a dictionary to another on a button click?

推荐答案

最简单的方法:

Simplest way:
Dictionary<mykeyclass,> d2 = d1.ToDictionary(k => k.Key, k => k.Value);

如果您只需要指定一些记录,请在之前添加Where调用ToDictionary。

If you need to specify just some of the records, add a Where call in there before the ToDictionary.


猜猜你想要对单个对象进行处理而不是对同一对象的引用。





Guess That you want work on individual objects not on references to the same object.


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:

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


这篇关于如何在单击按钮时将值从字典复制到另一个字典?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆