Hello i'm new to csharp and i experiment alot to see and solve difficult problems, however is one is a new error and i havent seen before:
"Wrong number of indices inside []; expected 1"
, i tryed to google it and try to solve it in my own way but i didnt find the solution. Could anyone help me solve this problem and say what i did wrong?
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]);
}
}
}
}
arrPlanetenis a one dimensional array, so you cannot acess it this way:arrPlaneten[i, 0,0,0]but onlyarrPlaneten[i].