i have a checkboxlist control
Use this single line of code:
int selectedCount = chkselectedItems.Items.Cast().Count(li => li.Selected);