Пора отучиться от привычки везде и всегда использовать if/else конструкции.
Объявим Dictionary с нужными нам чек боксами с формы:
Dictionary<CheckBox, Action> CheckBoxes;
public Form1()
{
InitializeComponent();
CheckBoxes = new Dictionary<CheckBox, Action>
{
[checkBox1] = () => Console.WriteLine(1),
[checkBox2] = () => Console.WriteLine(2),
[checkBox3] = () => Console.WriteLine(3),
[checkBox4] = () => Console.WriteLine(4),
[checkBox5] = () => Console.WriteLine(5),
[checkBox6] = () => Console.WriteLine(6),
[checkBox7] = () => Console.WriteLine(7),
[checkBox8] = () => Console.WriteLine(8),
[checkBox9] = () => Console.WriteLine(9),
[checkBox10] = () => Console.WriteLine(10),
[checkBox11] = method11,
};
}
Опишем method11:
void method11()
{
Console.WriteLine(11);
}
А теперь реализуем нажатие на кнопку:
private void button1_Click(object sender, EventArgs e)
{
foreach (var item in CheckBoxes.Where(x => x.Key.Checked).Select(x => x.Value))
{
item?.Invoke();
}
}
Отмечаем любые/все чек боксы на форме и наблюдаем за окном вывода.