Object passed as parameter to another class, by value or reference?

前端 未结 7 1726
闹比i
闹比i 2021-02-18 21:12

In C#, I know that by default, any parameters passed into a function would be by copy, that\'s, within the function, there is a local copy of the parameter. But, what about when

7条回答
  •  旧巷少年郎
    2021-02-18 21:46

    If you need to copy object please refer to object cloning, because objects are passed by reference, which is good for performance by the way, object creation is expensive.

    Here is article to refer to: Deep cloning objects

提交回复
热议问题