Value Parameter Example In C Sharp
This program descirbe the concept of pass by value (Value Parameter in C#)
---------------------------------------------------------------------------------------------
using System;
class ValueParameter
{
static void Main()
{
int a = 10;
Console.WriteLine("Value of a before calling method is " + a);
Console.WriteLine("--------------------");
ChangeValueMethod(a);
Console.WriteLine("--------------------");
Console.WriteLine("Value of a after calling method is " + a);
}
static void ChangeValueMethod(int a)
{
a += 10;
Console.WriteLine("Value of a is " + a);
}
}
-------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------
Note : - While we make change in the variable value of the formal parameter they will not reflect changes to the variable value of the actual parameter.
Actual parameter is
int a;
ChangeValueMethod(a);
Formal parmeter is
static void ChangeValueMethod(int a)
{
a += 10;
}
--------------------------------------------------------------------------------------------
Value Parameter Example In C Sharp
Reviewed by Baljeet Singh
on
01:48
Rating:
![Value Parameter Example In C Sharp](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhlM-wK73UTTr7V1AqhjyDLoLWa-4WYhYcPtw2FeTpAbd3D3aozUE8qJvw2_Ra-Wo7wIQZ_1NydPRrANEZtCUGyaznAYFKCI931yy49M03aEKO6PNQ43FjW38FA8fCzOt-Z3zOqna9CWTJt/s72-c/img.png)
No comments: