This program help you to pass int value by reference and when you pass a value you can modify it inside function only. As you can see the output is 5 more than the privious value.
using System;
namespace ConsoleHub
{
class Programs
{
static void Main(string[] args)
{
int Org_Value = 4;
Console.WriteLine("Original Value: {0}", Org_Value);
Add5(ref Org_Value);
Console.WriteLine("Modified Value: {0}", Org_Value);
Console.ReadLine();
}
static void Add5(ref int intValue)
{
intValue = intValue + 5;
}
}
}
No comments:
Post a Comment