C# looping through an array

后端 未结 7 2094
一生所求
一生所求 2021-01-07 20:16

I am looping through an array of strings, such as (1/12/1992 apple truck 12/10/10 orange bicycle). The array\'s length will always be divisible by 3. I need to loop through

7条回答
  •  [愿得一人]
    2021-01-07 20:24

    Here is a more general solution:

    int increment = 3;
    for(int i = 0; i < theData.Length; i += increment)
    {
       for(int j = 0; j < increment; j++)
       {
          if(i+j < theData.Length) {
             //theData[i + j] for the current index
          }
       }
    
    }
    

提交回复
热议问题