I have an occasion of code in which I will draw a different set of buttons in a screen (depending on the number of the buttons). One thought (and my current implementation) is to use an action array and call a different action
Action[] array = new Action[9];
array[0] = one;
array[1] = two;
array[2] = three;
array[3] = four;
array[4] = five;
array[5] = six;
array[6] = seven;
array[7] = eight;
array[8] = nine;
array[buttons.Count - 1]();
So depending on the number of buttons I call the specific drawing method. Another implementation might be using switch case and would look like something this
switch(buttons.count){
case 1: one(); break;
case 2: two(); break;
.
.
.
.
case 9: nine();break;
}
Are there any pros and cons of using versus the other? Are there any efficiency differences?