Bu programda diziler ve randomla sayısal loto programı yapacağız.
Formumuza 1 Button ve 1 Listbox ekliyoruz ve button'un click olayına aşağıdaki kodu yazıyoruz.
int[] dizi= new int[6];
private **** button1_Click(object sender, EventArgs e)
{
listBox1.Items.Clear();
int no = 1;
Random sayi = new Random();
for(int i=0;i<6
{
no = sayi.Next(1, 50);
if (Array.IndexOf(dizi, no) == -1)
{
dizi = no;
i++;
}
}
Array.Sort(dizi);
foreach (int deger in dizi)
{
listBox1.Items.Add(deger.ToString());
}
}
ALINTI
Formumuza 1 Button ve 1 Listbox ekliyoruz ve button'un click olayına aşağıdaki kodu yazıyoruz.
int[] dizi= new int[6];
private **** button1_Click(object sender, EventArgs e)
{
listBox1.Items.Clear();
int no = 1;
Random sayi = new Random();
for(int i=0;i<6
{
no = sayi.Next(1, 50);
if (Array.IndexOf(dizi, no) == -1)
{
dizi = no;
i++;
}
}
Array.Sort(dizi);
foreach (int deger in dizi)
{
listBox1.Items.Add(deger.ToString());
}
}
ALINTI