Friday, 12 February 2016

C Sharp Program how to Implement Pass by Value Parameter

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
------------------------------------------------------

No comments:

Post a Comment