Quantcast
Channel: Active questions tagged return-value - Stack Overflow
Viewing all articles
Browse latest Browse all 230

Best practice: ref parameter or return value?

$
0
0

Actually I am doing a list as a reference parameter as follows:

public static List ListMethod(List result)

I saw some people doing in this way too:

public static void ListMethod(ref List result)

If I'm not wrong, "my" method also takes the list as reference parameter, and you should be able to use it just the same way as "other" does in his method.

But it seems more "clean" to me that you enter a parameter, do something with it and return it in the methods return value.

Any good arguments for or against one method or the other?


Viewing all articles
Browse latest Browse all 230

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>