我的C#程序有问题:我创建了一个包含10个问题和10个图像的测验.我得到这个Length cannot be less than zero.\r\nParameter name: length在线路
int imageIndex = int.Parse(line.Substring(0, delimiter));
Run Code Online (Sandbox Code Playgroud)
即使在我的记事本文件中,我也包含了图像索引:
3:What is the foo in the bar?
10:How can you add a widget?
4:Why pick a bar over a foo?
Run Code Online (Sandbox Code Playgroud)
这是代码:
if (nr >= questions.Count)
{
button1.Enabled = false;
}
else
{
Random r = new Random();
int x;
do
{
x = r.Next(questions.Count);
}
while (questions[x].displayed == true);
textBox1.Text = questionText;
radioButton1.Text = questions[x].answer1;
radioButton2.Text = questions[x].answer2;
questions[x].displayed= true;
current_question = x;
}
Run Code Online (Sandbox Code Playgroud) c# ×1