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

CsharpProgrammingServer Side Programming

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.

Updated on 30-Jul-2019 22:30:23