//https://mustafabukulmez.com/2020/01/12/c-argumentoutofrangeexception-nedenleri-ve-kullanimi/ #endregion #region IndexOutOfRangeException Çıkarma ve Yakalama Örneği private void btn_IndexOutOfRangeException_Click(object sender, EventArgs e) { //int[] arr1 = new int[5]; //arr1[0] = 1; //arr1[1] = 2; //arr1[2] = 3; //arr1[3] = 4; //arr1[4] = 5; //int ii = arr1[5]; //int[] arr = new int[5]; //arr[0] = 0; //arr[1] = 1; //arr[2] = 2; //arr[3] = 3; //arr[4] = 4; //for (int i = 0; i < arr.Length + 1; i++) //{ // arr[i] = arr[i] + 1; //} try { _000_Classlar.Misafirler misafir1 = new _000_Classlar.Misafirler("Mustafa", "Bükülmez", 57); MessageBox.Show(misafir1.MisafirBilgi()); } catch (IndexOutOfRangeException ex) { txt_cikti.Text += ex.GetType().Name + ":" + ex.Message + Environment.NewLine; } }
//https://mustafabukulmez.com/2020/01/11/c-argumentnullexception-nedenleri-ve-kullanimi/ #endregion #region ArgumentNullException Çıkarma ve Yakalama Örneği private void btn_ArguOutOfRangeExce_Click(object sender, EventArgs e) { txt_cikti.Text = ""; // Hata Veren Örnek //string s = "1234"; //try //{ // bool b = Char.IsNumber(s, 5); //} //catch (ArgumentOutOfRangeException ex) //{ // txt_cikti.Text += ex.GetType().Name + ":" + ex.Message; //} try { _000_Classlar.Misafirler misafir1 = new _000_Classlar.Misafirler("Mustafa", "Bükülmez", 17); MessageBox.Show(misafir1.MisafirBilgi()); } catch (ArgumentOutOfRangeException ex) { txt_cikti.Text += ex.GetType().Name + ":" + ex.Message + Environment.NewLine; } }