using System;
class PassValueByParameter
{
static void Cube(int i)
{
i = i * i * i;
Console.WriteLine("Value Within the Cube method : {0}", i);
}
static void Main()
{
int num = 10;
Console.WriteLine("Value Before the Method is called : {0}", num);
Cube(num);
Console.WriteLine("Value After the Method is called : {0}", num);
Console.ReadKey();
}
}
------------------------
OUTPUT:-
Value Before the Method is called : 10
Value Within the Cube method : 1000
Value After the Method is called : 10
class PassValueByParameter
{
static void Cube(int i)
{
i = i * i * i;
Console.WriteLine("Value Within the Cube method : {0}", i);
}
static void Main()
{
int num = 10;
Console.WriteLine("Value Before the Method is called : {0}", num);
Cube(num);
Console.WriteLine("Value After the Method is called : {0}", num);
Console.ReadKey();
}
}
------------------------
OUTPUT:-
Value Before the Method is called : 10
Value Within the Cube method : 1000
Value After the Method is called : 10
------------------------------------------------------
No comments:
Post a Comment