Replies: 2 comments 5 replies
-
MemberwiseClone creates a shallow copy, not a deep copy. The Dictionary itself is not cloned, only myObject is. This is also a question for the runtime repository. |
Beta Was this translation helpful? Give feedback.
-
Here's a compiling version of that code snippet, demonstrating that "the value of my Parameters["dd"] in apiCopy" is 4, not 17, when this code runs: https://sharplab.io/#v2:C4LgTgrgdgPgAgJgIwFgBQcAMACOSAsA3OugLYCeA8gEYBWApgMbDYCGADgJbYC82U9AO7YKNBswAUASmJoOnAHQAFVmFal6wemADOCgIIATQxIBEx0wBpsppAHZTMslTpMW8gMIB7duV5suBQARenp2b19pWU8fcmVVdU1tHQBtc0NTAF1/U3xTWTwATgkY33i1DS1dNItMpzR0OABmXAQRF3EWAG8SDBagzmZOLyhVcgAePExrKYA+bBUKpN1/AWEBoZGxyaRp3F3ZqN7m9rE3bBCwiPJpdB60bEfT12ZsL2AAC21/CVEX4Ckn04egAsvRSNRtIJgfQPAAbEb0I4PJ5wOxvT7aWQAX3QuLQQA= |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello,
I did something that we could resume like this today :
After this, the value of my Parameters["dd"] in apiCopy is still 17 whereas I did a MemberwiseClone(). It is very confusing that the value didn't change whereas the object was supposed to be cloned.
Beta Was this translation helpful? Give feedback.
All reactions