I'm having a mental block at the moment. Basically I have a collection of objects so I'm wanting to loops through the collection until a certain set of values are reached and then return the Index of the item which meets this criteria.
Problem is if i'm correct it will return every time it gets to the next item in the loop thereby re-setting the value of the returned item.
Therefore i need a method of breaking out of the for loop once the correct item has been returned.
I've tried the following code, problem being is that the "break" statement is quite unreachable and I can't for the life of me how to rectify this.
Oh and it also complains about not all code paths returning a value which is true i suppose.Code:public int CurrentIndex() { for(int n=0;n<Images.Count;n++) { if(Images[n].PosX == 0 & Images[n].PosY == 0) { return Images.IndexOf(Images[n]); break; } else return -1; } }