I think JB was alluding to getting rid of the odd foreach and GetPos
then you can just say
for(int i=0;i<values.Count;i++) {
values[i]
}
since pos is just the index into the array.
Cheers,
Greg
On Fri, Oct 24, 2014 at 9:23 PM, <[email protected]> wrote:
> Hey JB,
>
> Thanks for your quick reply :P
> I now understand the problem, tho I am not sure how to fix it.
> The problem is that it find already the same number earlier, which has
> already been used before, so it already
> exits before, instead of continue looping till the next correct solution.
> I recoded this in a for loop as you told me:
>
> private static int getPos(int[] items, int item)
> {
> for (int i = 0; i < items.Length; i++)
> {
> if (items[i] == item)
> {
> return i;
> }
> }
> throw new Exception("No match for index");
> }
>
> Still, I am unsure how I would make sure that it will continue after the
> first possible match, since the arrays are dynamic and i dont know the size.
> Do you have an idea how I could change my code, so I will always return the
> correct index?
>
> --
> --
> --
> mono-cecil
> ---
> You received this message because you are subscribed to the Google Groups
> "mono-cecil" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.
--
Studying for the Turing test
--
--
--
mono-cecil
---
You received this message because you are subscribed to the Google Groups
"mono-cecil" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.