Tuesday, 6 August 2013

wpf nested foreach index array out of bounds

wpf nested foreach index array out of bounds

i created 2 foreach loop and i am getting error ( index outside of bounds
of array ) , because i use 2 arrays .
This is what i do :
using (StreamReader reader =
File.OpenText(@"C:\Users\apr13mpsip\Documents\Visual Studio
2010\Projects\iStellarMobile\iStellarMobile\Puzzle\educational.txt"))
{
string line;
while ((line = reader.ReadLine()) != null) // read line by line.
{
column = line.Split(new string[] { "," },
StringSplitOptions.None);
rowcol = column;
}
int i = 0;
int j = 0;
foreach (string r in rowcol)
{
foreach (string c in column)
{
var currentValue = rowcol[i][j];
j++;
}
i++;
}
}
i have already global string[] column; and string[] rowcol;
Error happens in this line :
var currentValue = rowcol[i][j];

No comments:

Post a Comment