private void button1_Click(object sender, EventArgs e) { if (textBox1.Text == "" || textBox1.Text.Contains("Input")) { MessageBox.Show("Input City"); return; } if (textBox2.Text == "" || textBox2.Text.Contains("Input")) { MessageBox.Show("Input Streat!"); return; } if (textBox3.Text == "" || textBox2.Text.Contains("Input")) { MessageBox.Show("Input NuberOfHouse!"); return; } if (textBox4.Text == "" || textBox2.Text.Contains("Input")) { MessageBox.Show("Input Flat!"); return; } if (textBox5.Text == "" || textBox2.Text.Contains("Input")) { MessageBox.Show("Input Index"); return; } Adress adress = new Adress(textBox1.Text, Convert.ToInt32(textBox5.Text), textBox2.Text, Convert.ToInt32(textBox3.Text), Convert.ToInt32(textBox4.Text)); bool bol = false; foreach (var item in Form1.adresses) { if (adress.City == item.City) { bol = true; } } if (!bol) { Form1.CreateAdress(adress); Form1.AllAdreses.Add(adress); } else { MessageBox.Show("This address is list"); } }