//Para compilar use: csc /target:winexe /out:HashSet.exe HashSet.cs HashSet.Designer.cs
using System;
using System.Collections.Generic;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
    public partial class HashSet : Form
    {
        public HashSet()
        {
            InitializeComponent();
        }

	[STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new HashSet());
        }

        private void button1_Click(object sender, EventArgs e)
        {
	    label1.Text="";
            HashSet<int> set = new HashSet<int>();
            set.Add(1);
            set.Add(2);
            set.Add(3);
            set.Add(4);
            set.RemoveWhere(isImpar);
            HashSet<int>.Enumerator exibe = set.GetEnumerator();
            while (exibe.MoveNext())
            {
                label1.Text+=exibe.Current.ToString() + "\n";
            }
        }

        private static bool isImpar(int i)
        {
            return ((i % 2) == 1);
        }
    }
}
