我有麻烦使用InputBox填充数组
本文关键字:InputBox 填充 数组 麻烦 | 更新日期: 2023-09-27 18:09:34
我在使用InputBox
填充数组时遇到麻烦。
private void btnOk_Click(object sender, EventArgs e)
{
int array;
int num;
string value = Interaction.InputBox("Enter Array size","Enter Array size");
if (int.TryParse(value, out array))
{
int[] Size = new int[array];
txtOutput.Text = "Numbers: " + "'r'n";
foreach (int i in Size)
{
string prompt = Interaction.InputBox("Enter values" + (i+1), "Enter values");
if(int.TryParse(prompt, out num))
txtOutput.Text += i + "'t";
}
}
}
string value = Interaction.InputBox("Enter Array size", "Enter Array size");
int array = 0;
if (int.TryParse(value, out array))
{
int[] size = new int[array];
txtOutput.Text = "Numbers: " + "'r'n";
for (int i = 0; i < size.Length; i++)
{
string prompt = Interaction.InputBox("Enter values" + (i + 1), "Enter values");
int num = 0;
if (int.TryParse(prompt, out num))
{
size[i] = num;
txtOutput.Text += size[i] + "'t";
}
}
}