1
Reply

How to make these in C#

Vlori Veliu

Vlori Veliu

Apr 20 2013 2:29 PM
1k
Plss can u help me about this how to make when I select the Capital City Madrid and City Spain to show me True or when I select Paris and France again True,,, and if I select Paris and Germany to show False ?


I have written these code but only for Madrid & Spain, how to make it works as well for others ( Paris with France, Berlin with Germany)?????

namespace example1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
listBox1.Items.Add("Madrid"); listBox1.Items.Add("Paris"); listBox1.Items.Add("Berlin"); listBox2.Items.Add("France"); listBox2.Items.Add("Germany"); listBox2.Items.Add("Spain");
}
private void button1_Click(object sender, EventArgs e)
{
if ((string)listBox1.SelectedItem == "Madrid" && (string)listBox2.SelectedItem == "Spain") MessageBox.Show("True","",MessageBoxButtons.OK, MessageBoxIcon.Information);
else
MessageBox.Show("False", "",MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}

Answers (1)