using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication2
{
class Program
{
/*
OlayUret metodunun parametresi için "ref" anahtar kelimesini kullanmazsak
metot çıkışında RastgeleOlay değişkenine atanan yeni değer unutulur.
Bu nedenle yeni atanan RastgeleOlay değerinin unutulmaması için "ref" anahtar kelimesini kullandık.
*/
static void OlayUret(ref int RastgeleOlay)
{
Random r=new Random();
RastgeleOlay =r.Next(4);
}
static void Main(string[] args)
{
//RastgeleOlay 0 olmalı yoksa while bloğuna giremeyiz.
int RastgeleOlay = 0;
int Altin = 10;
while (RastgeleOlay == 0)
{
OlayUret(ref RastgeleOlay);
Altin--;
Console.WriteLine("Altın : "+Altin+" , RastgeleOlay : "+RastgeleOlay);
}
Console.ReadKey();
}
}
}