In the groupBox control, there are four checkBox element and their tags' names are 1, 2, 3, 4. checkBox1, checkBox3 and checkBox4 are selected. Here is the screenshot:
I want to add selected checkbox items' tag to List item. I tried like this:
private void button1_Click(object sender, EventArgs e)
{
List<int> filter = new List<int>();
var add_tags = groupBox1.Controls.OfType<CheckBox>().Where(cb => cb.Checked).ForEach(cbx => filter.Add(Convert.ToInt32(cbx.Tag)));
}
But it returns error and I don't understand the error.
Here is the screenshot:

