viv*_*ous 2 c# asp.net arrays arraylist dynamic
我一直在为不同的控件创建数组,如下所示:
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];
Run Code Online (Sandbox Code Playgroud)
是否有任何方法来创建它们,以便我不需要指定大小/长度?即是否可以使这些控制数组的大小可变?
谢谢!
如果要允许任意数量的元素使用List类,则必须为数组指定长度,如下所示
List<TextBox> textBoxList=new List<TextBox>();
Run Code Online (Sandbox Code Playgroud)
并将控件添加到此集合中
textBoxList.Add(new TextBox());
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
209 次 |
| 最近记录: |