i trying write c# code unity read text file, store each line in string array, , convert 2d char array.
the error occurs at:
void readfile() { streamreader read = new streamreader(application.datapath + "/maze1.txt"); int length = read.readline().length; maze = new string[length, length]; line = new string[length]; while(!read.endofstream) { (int = 0; <= length; i++) { line[i] = read.readline(); } for( int = 0; <= length; i++) { for( int j = 0; j <= length; j++) { maze[i,j] = line[i].split(','); // <---this line issue. } } } }
the exact error getting is:
cannot implicitly convert type 'string[]' 'string'
what error mean , how fix code?
i have feeling meant this:
for( int = 0; <= length; i++) { var parts = line[i].split(','); for( int j = 0; j <= length; j++) { maze[i,j] = parts[j]; } }