In C#, Is it slower to reference an array variable?

后端 未结 5 2131
轮回少年
轮回少年 2020-12-18 18:02

I\'ve got an array of integers, and I\'m looping through them:

for (int i = 0; i < data.Length; i++)
{
  // do a lot of stuff here using data[i]
}
         


        
5条回答
  •  离开以前
    2020-12-18 19:06

    Not really sure, but it probably wouldn't hurt to store the value if you are going to use it multiple times. You could also use a foreach statement :)

提交回复
热议问题