当前位置:网站首页>How to clone objects
How to clone objects
2022-07-04 05:34:00 【Zafo】
problem :
When I do the following.. anything done to Person b modifies Person a (I thought doing this would clone Person b from Person a). When I do the following …… For personnel b Everything you do will change people a( I think doing so will help people a Clone people b).I also have NO idea if changing Person a will change Person b after the linking. I also don't know who will change after the link a Whether the personnel will be changed b.Due to my code right now, I can only see this in 1 direction. Because of my current code , I can only be in 1 See this in two directions .
Person a = new Person() { head = "big", feet = "small" };Person b = a; b.head = "small"; //now a.head = "small" too Now if I do this instead.. Person a becomes completely separate. Now? , If I do this instead .. people a Become completely independent .
Person b = new Person() { head = a.head, feet = a.feet };Now this fine and kinda makes sense when comparing this behaviour to other things in C#. Now? , When this behavior is compared with C# When comparing other things in , This is good and reasonable .BUT, this could get very annoying with large objects. however , For large objects , This can be very annoying .
Is there a way to shortcut this at all? Is there any way to shorten this ?
Such as: Such as :
Person b = a.Values;
Solution :
Reference resources : https://stackoom.com/en/question/MUCc边栏推荐
- Integer type of C language
- Character types of C language
- [matlab] matlab simulation modulation system FM system
- With the advent of the IP era, how can E-sports hotels take advantage of the "east wind" of games?
- VB. Net calls ffmpeg to simply process video (class Library-6)
- 谷歌 Chrome 浏览器将支持选取文字翻译功能
- Zhongke Panyun - module a infrastructure setting and safety reinforcement scoring standard
- left_and_right_net可解释性设计
- [matlab] matlab simulation - low pass Gaussian white noise
- [技术发展-25]:广播电视网、互联网、电信网、电网四网融合技术
猜你喜欢
![BUU-Crypto-[HDCTF2019]basic rsa](/img/d0/8e451dabb2a6897f6680220d16d04d.jpg)
BUU-Crypto-[HDCTF2019]basic rsa

VB.net GIF(制作、拆解——优化代码,类库——5)

(4) Canal multi instance use

2022 R2 mobile pressure vessel filling retraining question bank and answers

Introduction To AMBA 简单理解

2022年T电梯修理操作证考试题库及模拟考试

Evolution of system architecture: differences and connections between SOA and microservice architecture

TCP状态转换图

Integer type of C language

空洞卷积、可变形卷积、可变形ROI Pooling
随机推荐
Penetration tool - sqlmap
JS string splicing enhancement
Principle and practice of common defects in RSA encryption application
[matlab] general function of communication signal modulation - generation of narrow-band Gaussian white noise
VB.net 调用FFmpeg简单处理视频(类库——6)
[Excel] 数据透视图
2022 a special equipment related management (elevator) examination questions simulation examination platform operation
Remote desktop client RDP
Introduction To AMBA 简单理解
XII Golang others
How to use postman to realize simple interface Association [add, delete, modify and query]
远程桌面客户端 RDP
fastjson
(4) Canal multi instance use
基于单片机的太阳能杀虫系统
Automated testing selenium foundation -- webdriverapi
[matlab] matlab simulation - narrow band Gaussian white noise
724. 寻找数组的中心下标
[matlab] matlab simulates digital baseband transmission system - digital baseband transmission system
力扣 第 300 场周赛