out and ref keywords in c#.

Total Post:48


 3251  View(s)
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. 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:

      Modified On Mar-29-2018 04:08:41 AM


Please check, If you want to make this post sponsored

You are not a Sponsored Member. Click Here to Subscribe the Membership.