privatevoid button1_Click(object sender, EventArgs e)
{
int i,a;
double sonuc=1;
a =int.Parse(textBox1.Text);
for (i = 1; i <= a; i++)
sonuc = sonuc * i;
MessageBox.Show(“sayının faktöriyeli=” + sonuc.ToString());
}
privatevoid button1_Click(object sender, EventArgs e)
{
int a, b, c;
double d,x2,x1,i;
a =int.Parse(textBox1.Text);
b =int.Parse(textBox2.Text);
c =int.Parse(textBox3.Text);
d = b * b – 4 * a * c;
if (d < 0)
MessageBox.Show(“Reel kök yoktur”);
if (d == 0)
{
i = (-b / 2 * a);
MessageBox.Show(“çift katlı tek kök var” + i.Tostring());
}
if (d > 0)
{
x1 = (-b +Math.Sqrt(d) / 2 * a);
x2 = (-b –Math.Sqrt(d) / 2 * a);
MessageBox.Show(“Reel kök var “ + x1.ToString() + x2.ToString());
}
}
privatevoid button1_Click(object sender, EventArgs e)
{
int a;
a =int.Parse(textBox1.Text);
switch(a)
{
case 1: MessageBox.Show(“Pazartesi”);break;
case 2: MessageBox.Show(“Salı”);break;
case 3: MessageBox.Show(“Çarşamba”);break;
case 4: MessageBox.Show(“Perşembe”);break;
case 5: MessageBox.Show(“Cuma”);break;
case 6: MessageBox.Show(“cumartesi”);break;
case 7: MessageBox.Show(“Pazar”);break;
default : MessageBox.Show(“1 ile 7 arasında bir değer giriniz”);break;
}
}
privatevoid button1_Click(object sender, EventArgs e)
{
int sayi,sayi2, sonuc;
sayi =int.Parse(textBox1.Text);
sayi2 =int.Parse(textBox2.Text);
sonuc = sayi + sayi2;
label2.Text = sonuc.ToString();
label1.Text =“+”;
}
privatevoid button2_Click(object sender, EventArgs e)
{
int sayi, sayi2, sonuc;
sayi =int.Parse(textBox1.Text);
sayi2 =int.Parse(textBox2.Text);
sonuc = sayi – sayi2;
label2.Text = sonuc.ToString();
label1.Text =“-“;
}
privatevoid button3_Click(object sender, EventArgs e)
{
int sayi, sayi2, sonuc;
sayi =int.Parse(textBox1.Text);
sayi2 =int.Parse(textBox2.Text);
sonuc = sayi * sayi2;
label2.Text = sonuc.ToString();
label1.Text =“*”;
}
privatevoid button4_Click(object sender, EventArgs e)
{
int sayi, sayi2, sonuc;
sayi =int.Parse(textBox1.Text);
sayi2 =int.Parse(textBox2.Text);
sonuc = sayi / sayi2;
label2.Text = sonuc.ToString();
label1.Text =“/”;
}
Bu ekranda gördüğümüz örneğin kodlarını c# da yazalım şimdi:
Aşağıda gördüğünüz gibi hangi işlemi yapmak istiyorsak o butonun click olayına kodlarını yazıyoruz.
privatevoid button1_Click(object sender, EventArgs e)
{
listBox1.Items.Add(textBox1.Text);
listBox1.Items.Add(textBox2.Text);
listBox1.Items.Add(textBox3.Text);
}
privatevoid button2_Click(object sender, EventArgs e)
{
textBox1.Clear();
textBox2.Clear();
textBox3.Clear();
}
privatevoid button3_Click(object sender, EventArgs e)
{
Close();
}