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 Kumar Arora
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 Kumar Arora or read 157 articles authored by Gaurav Kumar Arora

Comments

Author: Gaurav Kumar Arora11 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: https://msdn.microsoft.com/en-IN/library/14akc2c7.aspx
https://msdn.microsoft.com/en-IN/library/t3c3bfhx.aspx

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:
    Email: