Sunday, 3 December 2017

C# Program to Demonstrate Pass by Reference Parameter


Code:

using System;
class Program
{
    static void Main(string[] args)
    {
        int val;
        val = 4;
        Console.WriteLine("Value Before : {0}", val);
        square(ref val);
        Console.WriteLine("Value After : {0}", val);
        Console.Read();
    }
    static void square(ref int refParam)
    {
        refParam *= refParam;
    }
}


Output:

Value Before : 4
Value After : 16


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