using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication4
{
class Program
{
public void sum(float a, float b)
{
float x=a + b;
Console.WriteLine(x);
}
public int changevalue(int x)
{
x = x * x;
return x;
}
public int changereference(ref int x)
{
x = x + x;
return x;
}
static void Main(string[] args)
{
Program p = new Program();
int a = 5;
Console.ForegroundColor = System.ConsoleColor.Red;
Console.WriteLine("call by value ..............................");
Console.ForegroundColor = System.ConsoleColor.White;
Console.WriteLine("value from function " + p.changevalue(a));
Console.WriteLine("actual value of a = "+a);
Console.ForegroundColor = System.ConsoleColor.Red;
Console.WriteLine("call by Reference ..............................");
Console.ForegroundColor = System.ConsoleColor.White;
Console.WriteLine("output from function : " + p.changereference(ref a));
Console.WriteLine("actual value of a = " + a);
Console.ReadLine();
}
}
}
No comments:
Post a Comment