This is my code , i am using 2 dimension array .
top = 0;
if(rowcol[i-1][j]){ top = rowcol[i-1][j] }
But it shows this error :
Cannot implicitly convert type 'string' to 'bool'
Full code :
string[] fileData = File.ReadAllLines(@"C:\Users\apr13mpsip\Desktop\OneOrganizer\OneOrganizer\WordPuzzle\testing.txt");
string[] lineValues;
int row = 0;
int col;
string[][] rowcol = new string[fileData.Length][];
foreach (string line in fileData)
{
lineValues = line.Split(new string[] { "," }, StringSplitOptions.None);
rowcol[row] = new string[lineValues.Length];
col = 0;
foreach (string value in lineValues)
{
rowcol[row][col] = value;
col++;
}
row++;
}
for (int i = 0; i < rowcol.GetLength(0) ; i++)
{
for (int j = 0; j < rowcol[i].GetLength(0) ; j++)
{
int iadd = i+1 <rowcol.GetLength(0) ? i + 1: 0;
int iminus = i-1> 0 ? i - 1 : 0;
int jadd = j+1 <rowcol.GetLength(0) ? j + 1 : 0;
int jminus = j-1 > 0 ? j - 1 : 0;
var self = rowcol[i][j]; // current value
top = 0;
if(rowcol[iminus][j]){ top = rowcol[iminus][j] } // ERROR HERE
}
}
i am actually reading from a textfile and creating something out of it by creating rows and cols 10x10 in a jagged array. so i could find their value by rowcol[][] .