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

前端 未结 7 1697
闹比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:45

    In general, an "object" is an instance of a class, which is an "image"/"fingerprint" of a class created in memory (via New keyword).
    The variable of object type refers to this memory location, that is, it essentially contains the address in memory.
    So a parameter of object type passes a reference/"link" to an object, not a copy of the whole object.

提交回复
热议问题