when should Ref be used

  • Thread starter Thread starter Vidyanand Kulkarni
  • Start date Start date
V

Vidyanand Kulkarni

Hello everybody,

when should be ref used. If we have object as input does ref makes
any difference?
In our code we are using lot of ref for object does this will give
different result if we do not use this

with regards
vidyanand kulkarni
 
Vidyanand Kulkarni said:
when should be ref used. If we have object as input does ref makes
any difference?
Absolutely.

In our code we are using lot of ref for object does this will give
different result if we do not use this

Yes. See http://www.pobox.com/~skeet/csharp/parameters.html for more
information.

My rule of thumb is to try to avoid pass-by-reference wherever possible
- write methods which do one thing and return one thing. Every so
often, it's useful to use ref or out parameters, but I find those cases
relatively rare.
 
Back
Top