views:

338

answers:

3
            int x;
        int iHateDataRows = dt.Rows.Count + 2;
        System.Data.DataRow[] dra = new System.Data.DataRow[1000];

        for(x = 0; x < iHateDataRows; ++x)

So, this is obviously a loop but, my problem is that the '++x' tells me that it is unreachable. I don't know if this is just my IDE going crazy or something (I use SharpDevelop, mostly because VS2008 is too clunky and doesn't have neat little features that I like.)

Anywho, I hope I provided enough info for someone to guess at the problem. I have stared at this thing, changed the variables. Everything, it won't budge.

EDIT:

This is after the for loop:

         if(dra[x].ItemArray[2].ToString() == "0")
         {
          return x.ToString();
         }
         else
         {
          return "Fail";
         }

I sure hope this code is correct as I never got to test it.

+5  A: 

You probably have a break or return (or, heaven forbid, goto) inside the loop.

SLaks
+7  A: 

You are always returning from the loop before it goes to the next iteration. That is, both halves of the "if" statement return. You never go back to the top of the loop.

Talljoe
AH!Silly me. >_>
Mashew
+4  A: 

Since either one or the other "if" clause in the loop will be executed, a return is guaranteed to occur, and the loop will never run a second iteration; thus, the increment will never take place.

mquander