您好,我是 csharp 的新手,我进行了很多实验以查看和解决难题,但是一个是新错误,我以前从未见过:
“[] 内的索引数量错误;预期为 1”
,我试图谷歌它并尝试以我自己的方式解决它,但我没有找到解决方案。谁能帮我解决这个问题并说出我做错了什么?
public Form1()
{
InitializeComponent();
}
class Planeet
{
public String Naam;
public Byte Grootte;
public Brush Kleur;
public short Afstand;
public Planeet(String argNaam, Byte argGrootte, Brush argKleur, short gAfstand)
{
Naam = argNaam;
Grootte = argGrootte;
Kleur = argKleur;
Afstand = argAfstand;
}
}
private void pbZonnestelsel_Click(object sender, EventArgs e)
{
Planeet[] arrPlaneten = new Planeet[9]
{
new Planeet("Mercurius", 4, Brushes.DarkGray, 4),
new Planeet("Venus", 10, Brushes.White, 20),
new Planeet("Aarde", 10, Brushes.LightBlue, 40),
new Planeet("Mars", 5, Brushes.Red, 60),
new Planeet("Jupiter", 112, Brushes.Orange, 80),
new Planeet("Saturnus", 94, Brushes.Beige, 200),
new Planeet("Uranus", 40, Brushes.Green, 300),
new Planeet("Neptunus", 38, Brushes.Blue, 350),
new Planeet("Pluto", 2, Brushes.LightGray, 400)
};
for (int i = 0; i < arrPlaneten.GetLength(0); i++)
{
listBox1.Items.Add(arrPlaneten[i, 0,0,0]);
listBox1.Items.Add(arrPlaneten[0, i, 0,0]);
}
}
}
}