I have following code:
for (int c = 0; c < date_old.Length; c++)
{
for (int d = 0; d < date_new.Length; d++)
{
newList[c] = data_old[c];
if (date_old[c] == date_new[d])
{
newList[c] = data_new[d];
}
}
}
What I'm trying to do is the following:
I have four arrays: date_new
, date_old
, data_new
, data_old
and a List called newList
.
date_old and data_old have the same length and date_new and data_new too.
I want to loop through the date arrays check if there are equal date values. While I'm doing this, I want to copy every value from the data_old array to newList. When a value is equal, I want to copy the value at this point from the data_new position into the List.
Here I get a OutOfBoundException
after the second for loop. What is wrong?