/* c#'ta matematiksel işlemlerde referans uygulaması */
using System;
class Test
{
//referans tipinde rInt ve rFloat nesneleri tanımlanıyor
private static void
Carp(ref int rInt,
ref float rFloat)
{
rInt = rInt * 2;
rFloat = rFloat * 2;
Bol(ref rInt, ref
rFloat);
}
//referans tipinde rInt ve rFloat nesneleri tanımlanıyor
private static void
Bol(ref int rInt,
ref float rFloat)
{
rInt = rInt / 3;
rFloat = rFloat / 3;
Topla(ref rInt, ref
rFloat);
}
//referans tipinde rInt ve rFloat nesneleri tanımlanıyor
public static void
Topla(ref int
rInt, ref float
rFloat)
{
rInt = rInt + rInt;
rFloat = rFloat + rFloat;
}
public void Run()
{
int yInt = 42;
float yFloat = 9.685f;
Console.WriteLine("Başlamadan
önce: \n yInt: {0} \n yFloat: {1}\n", yInt, yFloat);
Carp(ref yInt, ref
yFloat);
Console.WriteLine("Bittikten
sonra: \n yInt: {0} \n yFloat: {1}\n", yInt, yFloat);
}
class mainDB
{
static void Main()
{
Test t = new Test();
t.Run();
}
}
