ref vs out in C# [duplicate]
Possible Duplicate:
Difference between ref and out parameters in .NET
When to use ref and when to use out ?
What is diff开发者_StackOverflow中文版erence between the both ?
How and where they are used ?
Please share an example showing difference between the both ref and out .
- Thanks.
To my understanding:
ref means passing a variable by reference, which means you pass a pointer to that variable and it will retain modifications after leaving the function.
out means basically the same, except that the variable must be assigned before the function is exited, pretty much like return statements must be met before the function reaches completion.
I would start here. Jon does a good job explaining it all:
http://www.yoda.arachsys.com/csharp/parameters.html
There's any number of examples online.
A quick Google search found this: http://www.c-sharpcorner.com/UploadFile/mahesh/out_and_ref11112005002102AM/out_and_ref.aspx
加载中,请稍侯......
精彩评论