0

here is my code and it gives me this error and i don't understand the solutions people give on the internet

explanations Ruutu is a class and maa is an instance of it. And Piirrä is an method of ruutu wich should draw the char of maa onto the console

precise error is Error CS0021 Cannot apply indexing with [] to an expression of type 'Ruutu'

Ruutu[,] ruudukko = new Ruutu[100,70];

for (int x = 1; x < 100; x++)
{
    for (int y = 1; y < 70; y++)
    {
        ruudukko[x, y] = maa;
    }
}

for (int x = 1; x < 100; x++)
{
    for (int y = 1; y < 70; y++)
    {                   
        ruudukko[x, y].Piirrä(_juurikonsoli, x, y); //"error line"
    }
}
Uwe Keim
  • 39,551
  • 56
  • 175
  • 291
  • 1
    Please post the full error + where (what line) the error is thrown. – Mathias R. Jessen Mar 26 '17 at 18:19
  • Ok im just going to go and cry because i failed as a programmer and i will never be a tech billionaire. Well if i look it positively i can now become and fulltime hippie and find true peace and happiness. – Kalle Laatunen Mar 30 '17 at 09:24

1 Answers1

0

Can you try the following instead of "error line":

Ruutu ruutu = (Ruutu)ruudukko[x, y];
ruutu.Piirrä(_juurikonsoli, x, y);
ozidom
  • 159
  • 1
  • 5