Hello,
It's a project in my school, I try to get a few dummy's position, and the direction, where they are going. I have to use methods, so I try to implement it in this way.
I got the error here:
babok = BeOlvasBabok("tabla.be,b");
where tabla.be is the name of the file, and b is a short number, and babok is a byte[,].
And it's definition is:
static byte[,] BeOlvasBabok(string filenev, short babszam)
{
byte[,] babok;
babok = new byte[3, babszam];
//first line reread, to start at the second line
StreamReader sr = new StreamReader("tabla.be");
string a = sr.ReadLine();
for (int i = 0; i != babszam; i++)
{
a = sr.ReadLine();
string[] c = a.Split(' ');
babok[0, i] = byte.Parse(c[0]);
babok[1, i] = byte.Parse(c[1]);
// converting the directions to numbers: down(l):1, up(f):2, right(j):3, left(b):4
switch (c[2])
{
case "l":
case "L":
babok[2, i] = 1;
break;
case "f":
case "F":
babok[2, i] = 2;
break;
case "j":
case "J":
babok[2, i] = 3;
break;
case "b":
case "B":
babok[2, i] = 4;
break;
default:
Console.WriteLine("Hiba a " + i + "-edik bevitt adatban!");
break;
}
sr.Close();
}
return babok;
}
I found a few similiar problems here, but unfortunately can't figure out, have to use them in my solution.
↧