Geeks With Blogs

News


Path Notes of a Kodefu Master blog

I recently came across a piece of code that had almost every parameter for every method marked with the ref keyword. This keyword is primarily used to pass a value type by reference, but this one even had reference types marked with the keyword. This made me wonder, why exactly would you ever want to pass a reference type as a ref parameter?

Read More

Posted on Friday, June 12, 2009 4:30 PM Kodefu | Back to top


Comments on this post: ref on Reference Type?!

# re: ref on Reference Type?!
Requesting Gravatar...
Keep in mindthat even a reference type is actually passed by value. If I pass a List<> list as a parameter to a function and say list = new List<> inside that function; the calling function will not see the changed List coming back. If all I do in the called function is modify the elements of the List that was sent to me, the caller will see the changes. If I passa ref List<>, the first scenario I described will work.
Left by Michael on Jun 15, 2009 2:31 PM

Your comment:
 (will show your gravatar)


Copyright © Chris Eargle | Powered by: GeeksWithBlogs.net