Ref modifier can use data value change in
another function.
class
Program
{
static void
Main(string[] args)
{
int number = 20;
int number1 = 20;
AddFive(ref
number);
AddFive1(number1);
Console.WriteLine(number);
Console.WriteLine(number1);
Console.ReadKey();
}
static void
AddFive(ref int
number)
{
number = number +
5;
}
static void
AddFive1(int number)
{
number = number +
5;
}
}
This simple c# program pass Two function value is same but one function use ref
keyword and other function do not use ref key word, two function include
operations are same but the operation affected only ref keyword function