OUT AND REF KEYWORDS IN C#.

James Smith

Total Post:48

Points:336
Posted by  James Smith
C# 
C#
 2879  View(s)
Ratings:
Rate this:
Could anyone please explain me in some detail with an example that what is difference between out and ref keywords in c#.
Thanks in advance.
  1. Amit Singh

    Post:103

    Points:721
    Re: out and ref keywords in c#.

    ref keywords:
    When we want change in passed parameter to the method then we pass it by reference with the help of ref keyword in actual and formal parameters. By passing parameter by reference actual address of the parameter is passed to the method and changes made to the parameter in method reflect in actual parameter passed.
    out Keywords
    Passing parameter by out is somewhat like ref but the difference is that it is unidirectional i.e. we do not need to initialize the passed variable but we get back the processed value. Likewise Reference parameter we need to use out before variable in output parameter.

    For Example:
    Please check this link:
    http://mindstick.com/Articles/bcf933f0-0140-4bc6-a725-4edb2743b988/

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!