Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does it make sense to pass a "reference type" to a method as a parameter with 'ref' key? [duplicate]

Possible Duplicate:
C#: What is the use of “ref” for Reference-type variables?

Hi,

Does it make sense to pass a "reference type" to a method as a parameter with 'ref' key?

Or it is just nonsense as it is already a reference type but not a value type?

Thanks!

like image 735
pencilCake Avatar asked Dec 27 '22 20:12

pencilCake


1 Answers

It lets you change the reference variable itself, in addition to the object it's pointing to.

It makes sense if you think you might make the variable point to a different object (or to null) inside your method.

Otherwise, no.

like image 115
user541686 Avatar answered Jan 17 '23 18:01

user541686