For loop not stopping after conditions are met.

I wanted to do something different and try out for loops but for some reason, my for loop is not stopping when both “i” and my list count equal to one. Is there something I’m missing?


                // Should stop when i is not less than list count
                for(int i = 0; i < truck.GetComponent<T_Info>().deliveryList.Count; i++) // Comparing "i" with list count
                {
                    // Goes through each item in list and determines income amount via loop
                    currentIncome += truck.GetComponent<T_Info>().deliveryList<em>.transform.GetComponent<I_Packed>().packedValue * 10;</em> 

i++;
Debug.Log(i);
}
----------
P.S: Sorry for the messy formating! Also all you need to know there is a list of game objects that I am comparing to “i” value.

@JustACode

First of all the obvious problem is that you increases “i” 2 times per loop

once at for(int i = 0; i < truck.GetComponent<T_Info>().deliveryList.Count; i++) and once at row 7 i++; remove it if you dont want it to skip every other number


“my for loop is not stopping when both “i” and my list count equal to one.”

I don’t quite understand what do you mean by that

you declared in the loop i < truck.GetComponent<T_Info>().deliveryList.Count; meaning while i is smaller then .deliveryList.Count the loop will run