programming-examples/c-sharp/Functions/C# Program to Demonstrate Pass by Value Parameter.cs

25 lines
611 B
C#
Raw Normal View History

2019-11-15 12:59:38 +01:00
/*
* C# Program to Demonstrate Pass by Value Parameter
*/
using System;
class program
{
static void Cube(int x)
{
x = x * x * x;
Console.WriteLine("Value Within the Cube method : {0}", x);
}
static void Main()
{
int num = 5;
Console.WriteLine("Value Before the Method is called : {0}", num);
Cube(num);
Console.WriteLine("Value After the Method is called : {0}", num);
Console.ReadKey();
}
}
/*
Value Before the Method is called : 5
Value Within the Cube method : 125
Value After the Method is called : 5