🙂 İNSANLARIN EN HAYIRLISI INSANLARA FAYDALI OLANDIR 🙂

Burak Kemal KOYUNCU / C# / Try catch hata blokları

1-) C# - Try catch hata blokları

 

 

 

  try

            {

                int s1, s2, sonuc;

                s1 = Convert.ToInt32(textBox1.Text);

                s2 = Convert.ToInt32(textBox2.Text);

                sonuc = s1 * s2;

                label1.Text = sonuc.ToString();

 

            }

            catch (Exception hata)

            {

                MessageBox.Show(hata.ToString());

               

            }

 

 try  //burayı dener çalıştırmaya calısır eğer calısmazsa catch blogunu calıstırır.

            {

                int s1, s2, sonuc;

                s1 = Convert.ToInt32(textBox1.Text);

                s2 = Convert.ToInt32(textBox2.Text);

                sonuc = s1 * s2;

                label1.Text = sonuc.ToString();

 

            }

            catch (Exception )

            {

                MessageBox.Show("Hata var burası çalıştır");

               

            }

            finally  //ne olursa olun programı calıstıran bloktur.

            {

                MessageBox.Show("");

            }

 2021 Ocak 21 Perşembe
 350