Сравнение чисел в лист боксах - C#
Формулировка задачи:
private void button1_Click(object sender, EventArgs e)
{
Random rnd = new Random();
string s;
for (int i = 0; i < 10; i++)
{
int[,] a = new int[10, 10];
s = "";
for (int j = 0; j < 10; j++)
{
a[i, j] = rnd.Next(10);
s += (a[i, j]).ToString() + " ";
}
listBox1.Items.Add(s);
}
}
private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
{
}
private void listBox1_SelectedIndexChanged_1(object sender, EventArgs e)
{
}
private void listBox2_SelectedIndexChanged(object sender, EventArgs e)
{
}
private void button2_Click(object sender, EventArgs e)
{
Random rnd = new Random();
string s;
for (int i = 0; i < 10; i++)
{
int[,] a = new int[10, 10];
s = "";
for (int j = 0; j < 10; j++)
{
a[i, j] = rnd.Next(10);
s += (a[i, j]).ToString() + " ";
}
listBox2.Items.Add(s);
}
}
private void button3_Click(object sender, EventArgs e)
{
private void listBox3_SelectedIndexChanged(object sender, EventArgs e)
{
}
Помогите плизик....
Решение задачи: «Сравнение чисел в лист боксах»
textual
Листинг программы
for(int i = 0; i < listBox1.Items.Count; i++)
{
for(int j = 0; j < listBox2.Items.Count; j++)
{
if(listBox1.Items.Contains(listBox2.Items[j]))
{
if(!listBox3.Items.Contains(listBox2.Items[j]))
{
listBox3.Items.Add(listBox2.Items[j]);
}
listBox1.Items.Remove(listBox2.Items[j]);
listBox2.Items.Remove(listBox2.Items[j]);
}
}
}