Sure:
foreach (CheckBox subset in groupBox_subset.Controls .Cast<CheckBox>() .Where(c => c.Checked)) { ... }
Cast is required because the Controls property implements only IEnumerable , not IEnumerable<T> , but LINQ mainly works on strongly typed collections. In other words, your existing code is actually closer to:
foreach(Object tmp in groupBox_subset.Controls) { CheckBox subset = (CheckBox) tmp; if(subset.Checked) { ... } }
If you want to ignore CheckBox , you should use OfType instead of Cast in the top fragment:
foreach (CheckBox subset in groupBox_subset.Controls .OfType<CheckBox>() .Where(c => c.Checked)) { ... }
source share