Why use the 'ref' keyword when passing an object?

后端 未结 11 1534
被撕碎了的回忆
被撕碎了的回忆 2020-11-22 06:45

If I am passing an object to a method, why should I use the ref keyword? Isn\'t this the default behaviour anyway?

For example:

class Program
{
    s         


        
11条回答
  •  粉色の甜心
    2020-11-22 07:41

    You need to distinguish between "passing a reference by value", and "passing a parameter/argument by reference".

    I've written a reasonably long article on the subject to avoid having to write carefully each time this comes up on newsgroups

提交回复
热议问题