如何从文本框中获取字符串值并将其存储在数组字符串中?点击摘要按钮后,它将数组显示为列表框中的列表。将文本框值存储在一个字符串数组中,并在列表框中显示数组
例如,用户在文本框中输入“Tom”。点击进入! Tom存储在数组中 用户在文本框中输入“Nick”并点击Enter! Nick被存储在阵列中等等。
最后,当用户点击摘要按钮,列表框显示是这样的:
汤姆
尼克
有人可以帮助我?非常感谢你!
这是到目前为止我的代码
//Button helps to display the total number of customers
private void viewCustomerSBtn_Click(object sender, EventArgs e)
{
//Displays the string of names that are stored in cNames
//Creates an array to hold Customer Names
string[] cNames = new string[100];
for (int i = 0; i < cNames.Length; i++)
{
cNames[i] = nameTextBox.Text;
reportListBox.Items.Add(cNames[i]);
}
我正在使用此窗体的Windows窗体应用程序。我发布了一段代码供我参考。你能给我一个代码的例子吗? –