What is the difference between pass by value and reference parameters in C#?


Reference Parameters

A reference parameter is a reference to a memory location of a variable. The reference parameters represent the same memory location as the actual parameters that are supplied to the method.

When you pass parameters by reference, unlike value parameters, a new storage location is not created for these parameters.

Pass by Value

This is the default mechanism for passing parameters to a method. In this mechanism, when a method is called, a new storage location is created for each value parameter.

The values of the actual parameters are copied into them. Hence, the changes made to the parameter inside the method have no effect on the argument.

karthikeya Boyini
karthikeya Boyini

I love programming (: That's all I know

Updated on: 30-Jul-2019

463 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements