private void button1_Click(object sender, EventArgs e) { if (YZ()) { if (string.IsNullOrEmpty(Xh)) { Lst.Add(new Student() { ID = textBox1.Text.Trim(), Name = textBox2.Text.Trim(), Age = int.Parse(textBox3.Text.Trim()), GenderText = textBox4.Text.Trim() }); } else { Student st1 = Lst.FirstOrDefault(c => c.ID == textBox1.Text); st1.Name = textBox2.Text.Trim(); st1.Age = int.Parse(textBox3.Text.Trim()); st1.GenderText = textBox4.Text.Trim(); } if (Handler != null) { Handler(); } } Close(); }