Ref – Out of C#

In this short video tutorial Gaurav Kumar Arora is going to demonstrate Ref – Out of C# with an example

The ref keyword causes argument passed by reference.

The effect is that any changes is made to the parameter in the method will be reflected in that variable when control passes back to the calling method.

To use a ref parameter, both the method definition and the calling method must explicitly use the ref keyword.

An argument passed to to a ref parameter must first be initialized. This differs it from out whose argument need not be explicitly initialize before being passed.

Both ref and out are treated differently at runtime, but treated the same at compilation. Therefore, methods can't be overloaded, if one method takes a ref keyword and the other takes an out argument.

Here is short video tutorial describing Ref-Out:

Article by Gaurav Aroraa
Gaurav is a Microsoft Technology Specialist professional. He has awarded lifetime membership from Computer Society of India (CSI). He has more than 13yrs of experience in the industry. Currently, he is working in the capacity of Solution Architect with an MNC. He is serving to the various communities since 1999.

Follow Gaurav Aroraa or read 149 articles authored by Gaurav Aroraa


Author: Gaurav Aroraa11 Jun 2015 Member Level: Gold   Points : 2

Hey Chitranjan,
Go through the full Video Tutorial and think what is all about.
You can refer msdn for more info:

If you want to discuss further, reach to me directly.

  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name: