Sunday 3 December 2017

C# Program to Demonstrate Pass by Value Parameter


Code:

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();
    }
}


Output:

Value Before the Method is called : 5
Value Within the Cube method : 125
Value After the Method is called : 5


More C# Programs:




















100+ Best Home Decoration Ideas For Christmas Day 2019 To Make Home Beautiful

Best gifts for Christmas Day | Greeting cards for Christmas Day | Gift your children a new gift on Christmas day This Christmas d...