【发布时间】:2014-11-23 16:48:14
【问题描述】:
当用户单击提交按钮时,我想将用户输入插入到数组中。 这是我写的,但它似乎不起作用。该表单称为form1,它是它自己的类,文本框是textbox1。注意:我是编程新手。
//This is my array
private string[] texts = new string[10];
public string[] Texts
{
get { return texts; }
set { texts = value; }
}
//I then attempt to insert the value of the field into the textbox
form1 enterDetails = new form1();
for(int counter = 0; counter<Texts.Length; counter++)
{
texts[counter]=enterDetails.textbox1.Text;
}
【问题讨论】:
-
什么不起作用?发生了什么?
-
您似乎粘贴了 2 或 3 个来自不同范围的代码,无法判断发生了什么
-
这可能无法解决您的问题,但仍然:一个属性的 setter 设置的变量与 getter 检索到的变量不同,这是一种 HUGE 代码气味
标签: c# arrays textbox windows-forms-designer windowsformsintegration