When debugging, pressing F10 successively reaches comboBox3.SelectedIndex = 1; and then goes not to textBox1.Text = "345"; , and on mas = new double [s]; in another class (second figure). And an error is presented presented in the second figure. int s is equal to a negative value, although this method is called further in the program and the value of s should not be obtained in any way negative. What is the problem?
Communication class "Signal" with the form:
private void Form1_Load(object sender, EventArgs e) { ... if (comboBox2.SelectedIndex == 0) { if (comboBox1.SelectedIndex == 0) { if (comboBox3.SelectedIndex == 0) { Сигнал SIN = Форм_Син.G_sin(F, n_pd, F_DISCR); userControl11.Length = SIN.size; for (int i = 0; i < SIN.size; i++) { userControl11.x[i] = i / F_DISCR; userControl11.y[i] = SIN[i]; } } else { Сигнал LCHM = Форм_ЛЧМ.G_LHCM(F, F_DISCR, basa, n_pd); userControl11.Length = LCHM.size; for (int i = 0; i < LCHM.size; i++) { userControl11.x[i] = i / F_DISCR; userControl11.y[i] = LCHM[i]; } } } } }
The second connection of the class "Signal" with the form:
private void comboBox3_SelectedIndexChanged(object sender, EventArgs e) { if (comboBox3.SelectedIndex == 0) { Сигнал SIN = Форм_Син.G_sin(F, n_pd, F_DISCR); userControl11.Length = SIN.size; for (int i = 0; i < SIN.size; i++) { userControl11.x[i] = i / F_DISCR; userControl11.y[i] = SIN[i]; } userControl11.P_ka(); } if (comboBox3.SelectedIndex == 1) { Сигнал LCHM = Форм_ЛЧМ.G_LHCM(F, F_DISCR, basa, n_pd); userControl11.Length = LCHM.size; for (int i = 0; i < LCHM.size; i++) { userControl11.x[i] = i / F_DISCR; userControl11.y[i] = LCHM[i]; } userControl11.P_ka(); } }