I have been creating arrays for different controls as follows, e.g:
private TextBox[] Array_TextBoxes;
private CheckBox[] Array_CheckBoxes;
private RadioButtonList[] Array_radioButton;
Array_TextBoxes= new TextBox[4];
Array_CheckBoxes= new CheckBox[5];
Array_radioButton= new RadioButtonList[10];
Is there any ways of creating them so that I do not need to specify the size/length? I.e. is it possible to make these control arrays variable sized?
Thanks!
Arrays must be assigned a length, if you want to allow for any number of elements use the List class, like this
List<TextBox> textBoxList=new List<TextBox>();
and add controls into this collection
textBoxList.Add(new TextBox());
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With