Unutulan Değil iz bırakan OL!
Süper Üye
Bu derste Try - Catch kullanarak ortalama hesaplayan bir program yapalım.
}
4 tane Textbox eklicez ilk 3 üne not yazıp butona tıklayınca 4. textbox da notu göstercek
Kod:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
int not1, not2, not3;
double ortalama;
try
{
not1 = int.Parse(textBox1.Text);
not2 = int.Parse(textBox2.Text);
not3 = int.Parse(textBox3.Text);
ortalama = (not1 + not2 + not3) / 3;
textBox4.Text = ortalama.ToString();
}
catch
{
MessageBox.Show("Hata Meydana Geldi n" + hata.Message, "Dikkat");
}
}