Possible Duplicate:
Difference between ref and out parameters in .NET
What is different between Out type and Ref type parameters in C#.net?
When we can use in which situation?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Both indicate to the caller that the method can modify the value of the parameter.
outparameters must be initialized inside the method whereasrefparameters might be initialized outside. It’s basically a contract. When you see a method that takes anoutparameter this means that that caller can invoke it without initializing the value and be sure that it will be initialized inside:whereas with ref:
It’s the caller’s responsibility to initialize the variable before calling the method: