C# looping through an array

后端 未结 7 2053
一生所求
一生所求 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:49

    i++ is the standard use of a loop, but not the only way. Try incrementing by 3 each time:

     for (int i = 0; i < theData.Length - 2; i+=3) 
        { 
    
            // use theData[i], theData[i+1], theData[i+2]
    
        } 
    
    0 讨论(0)
提交回复
热议问题