I have Checkboxes
within my application and if one is checked, a value has to be added to a List
/ Array
Question: Is there a way to write this code more simple / smart?
My Approach:
List<string> animals = new List<string>();
if (CheckBox_dog.Checked == true)
animals.Add("dog");
if (CheckBox_cat.Checked == true)
animals.Add("cat");
if (CheckBox_horse.Checked == true)
animals.Add("horse");
if (CheckBox_duck.Checked == true)
animals.Add("duck");
if (CheckBox_chicken.Checked == true)
animals.Add("chicken");
if (CheckBox_cow.Checked == true)
animals.Add("cow");
if (CheckBox_pig.Checked == true)
animals.Add("pig");