Pass by value parameters in C#

When parameters declared with no modifier and passed by value called by value parameter. When a method is invoked, the values of the actual parameters are assigned to the corresponding parameters and values of the value parameters can be changed with in method. The value of parameters that is passed by value does not change by the corresponding formal parameters. you can understanding this thing from below:

pass by value parameters

see the example:

class Shape
     public void main()
        int i = 5;
        int areaOfSquare = GetNumber(i);
    public int GetNumber(int x)
       int x= x +5;
       return x;

we can see from above any changes in x does not affect the value stored in the location of i.

Author: Hirendra Sisodiya

Programmer at PSPL. Can be found on Google Plus.