Advertisement
Guest User

Untitled

a guest
Apr 6th, 2020
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.60 KB | None | 0 0
  1. private void button1_Click(object sender, EventArgs e)
  2.         {
  3.             listBox1.Items.Add(textBox1.Text);
  4.             textBox1.Text = "";
  5.         }
  6.  
  7. private void button2_Click(object sender, EventArgs e)
  8.         {
  9.             string s = "";
  10.             foreach(var c in listBox1.SelectedItems)
  11.             {
  12.                 if(int.TryParse(c.ToString(), out int o))
  13.                 {
  14.                     if(o%2 == 0)
  15.                     {
  16.                          s += $"{o.ToString()}\n";
  17.                     }
  18.                 }
  19.             }
  20.             MessageBox.Show(s);
  21.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement