Dies ist mein Code:Einfach C# Fehler
namespace ConsoleApplication3
{
class Module1
{
static void Main()
{
int i;
int j;
int[,] matriceFoglio;
string stringa = "";
for (i = 1; (i <= 11); i++)
{
stringa = "";
for (j = 1; (j <= 11); j++)
{
matriceFoglio(i, j) = 0;
stringa = (stringa + matriceFoglio[i,j]);
}
Console.WriteLine(stringa);
}
Console.ReadLine();
// disegno l'albero di natale
matriceFoglio[1, 5] = 1;
matriceFoglio[2, 4] = 1;
matriceFoglio[2, 5] = 1;
matriceFoglio[2, 6] = 1;
matriceFoglio[3, 3] = 1;
matriceFoglio[3, 4] = 1;
matriceFoglio[3, 5] = 1;
matriceFoglio[3, 6] = 1;
matriceFoglio[3, 7] = 1;
matriceFoglio[4, 5] = 1;
matriceFoglio[5, 5] = 1;
// disegno l'albero
Console.WriteLine("");
for (i = 1; (i <= 11); i++)
{
stringa = "";
for (j = 1; (j <= 11); j++)
{
stringa = (stringa + matriceFoglio[i, j]);
}
Console.WriteLine(stringa);
}
Console.ReadLine();
}
}
}
In der for-Schleife der Compiler diesen Fehler führt:
Method name expected and Use of unassigned local variable 'matriceFoglio'.
Ich verstehe nicht, was ich falsch mache.
Ändern Sie 'int [,] matriceFoglio' in' int [,] matriceFoglio = new int [1000,1000]; '. "Warum 1000?", Kein Grund. – Quantic
nein 1000, aber 10. –