.NET Parameter passing - by reference v/s by value

后端 未结 6 1055
抹茶落季
抹茶落季 2020-12-15 06:05

I\'m trying to validate my understanding of how C#/.NET/CLR treats value types and reference types. I\'ve read so many contradicting explanations I stil

This is what

6条回答
  •  萌比男神i
    2020-12-15 06:55

    When you pass a person, it is making a copy of the reference - do not confuse this with a copy of the object. In other words, it is creating a second reference, to the same object, and then passing that.

    When you pass by ref (with the ref/out keyword), it is passing the same reference to the object that you are using in the caller, rather than creating a copy of the reference.

提交回复
热议问题