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

23 lines
475 B
C#
Raw Normal View History

2019-11-15 12:59:38 +01:00
/*
* C# Program to Demonstrate Pass by Reference Parameter
*/
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;
}
}
/*
Value Before : 4
Value After : 16