Why is the original object changed after a copy, without using ref arguments?

后端 未结 4 2056
渐次进展
渐次进展 2020-12-16 08:08

At work we were encountering a problem where the original object was changed after we send a copy through a method. We did find a workaround by using IClonable

4条回答
  •  太阳男子
    2020-12-16 08:37

    The docs at MSDN say it pretty clearly. Value types are passed as a copy by default, objects are passed as a reference by default. Methods in C#

提交回复
热议问题