So, what's so wonderful? You just have two array with different lengths. You index range goes outside one of the arrays. OK, I feel my previous answer could help. You previous question was deleted, which is too bad (who did it?!!).
You code simply does not have much sense.
However… this task makes some sense if made generalized. First, let's make an array element a generic parameters, because the problem does not really depend on it. Let's make the number of arrays arbitrary, number of elements in each array arbitrary and abstract our the conditions. Also, let's make a number of conditions arbitrary.
That can make some sense, at least remotely; and of course the ad-hoc problem would not have much sense. What, with hard-coded array ranges, etc.? Come on…
This set of input data will generate more then one method checking up the condition, because — how to define what is the check? I'll show just one of such predicate method, the one which validates that all conditions for all array elements are held true:
static bool AllConditionsValidForAllArrayElements<T>(
T[][] arrays,
System.Func<int,
T, bool>[] conditions)
{
foreach (T[] array in arrays) {
int index = 0;
foreach(T element in array)
foreach (System.Func<int, T, bool> condition in conditions) {
if (!condition(index, element))
return false;
++index;
}
}
return true;
}
[EDIT] Using the same principle, one could build different predicates on this data set, such as "at least one array element satisfies at least one condition", "at least one array element satisfies all conditions", "all elements of at least one array satisfy at least on condition", "all elements of at least one array satisfy all conditions", "at least one condition is satisfied by all array elements", etc. The one who can list all of them is at least a good student. :-)
Only one problem here: the simplest analysis shows that the nested cycles is better in performance than any thinkable ways of merging them in one cycle, so what? I've warned about the fantasy in my comment to the first version of this question…
—SA