I want to run a for loop where its initialiser and condition are based on the values of an integer array. for eg:-
int[] array = [0,5,8,12..]
for(initialiser = array[0], condition < array[1], initialiser++)
{
//program condition is satisfied.
break;
}
in the first looop initialiser is array[0] and condition is array[1]
in the second loop initialiser is array[1] and condition is array[2]
and so on array lenght is not fixed.So far i am unable to make it work efficiently.
This is what is have tried.
int idx = 0;
foreach (int id in oId)
{
if (id != oId.Last())
{
for (int k = 1; k < oCnt; k++)
{
for (int j = id; j < oId[k]; j++)
{
//Logic condition is satisfied vId is an array here
}
}
r[idx++] = vId[0];
}
if (id == oId.Last())
{
for (int j = oId.Last(); j < totalLength; j++)
{
//Logic condition is satisfied vId is an array here
}
r[idx++] = vId[0];
}
}