I can't see a good reason for that error, but I'd try moving the code about a bit:
for (int j = 0; j <= ttarray.Length; j++)
{
foreach(DataRow dr in dt.Rows)
{
row++;
string dayName = dr["DayName"].ToString();
foreach(DataColumn dc in dt.Columns)
{
col++;
if ((dayName==ttarray[j].DayName) && (dc.ColumnName == ttarray[j].HourName))
{
string FullName = ttarray[j].LastNameFaculity +" "+ttarray[j].FirstNameFaculity;
string week;
dt.Rows[row][col] = FullName + ttarray[j].LessonName + week;
}
}
}
I'd probably also extract the
ttarray[j]
to a named class instance:
MyClass whateverThisIsSupposedToBe = ttarray[j];
And use the name throughout instead. (The optimiser will probably do that for you, but it makes the code a little more readable)
That may remove the error.
}