C# random , C# while döngüsü kullanılarak rastgele sayı oluşturma ve negatif sayı oluşturulduğunda sonlanan döngü örneği.
Rastgele oluşturulan sayı negatif olduğunda sonlanan döngü.
Random rnd = new Random();
int n =rnd.Next(0, 100);
Console.Write("Rastgele Sayı..: {0} ", n);
Console.ReadLine();
Rastgele oluşturulan sayı negatif olduğunda sonlanan döngü.
int n=0;
do
{
Random rnd = new Random();
n = rnd.Next(-100, 100);
Console.Write("Rastgele Sayı..: {0} ", n);
Console.ReadLine();
}
while (n > 0);
Console.ReadLine();