码迷,mamicode.com
首页 > Windows程序 > 详细

C# for循环提升效率的写法

时间:2020-01-09 13:01:25      阅读:169      评论:0      收藏:0      [点我收藏+]

标签:length   var   div   i++   code   很多   style   需要   for循环   

//下列for写法比一般的for写法要快很多,时间紧 ,大概的思路是其只需要计算一次length 
1
int[] arr={1,2,3,4,5,6}; 2 for(int i=0,iLen=arr.Length;i<iLen;i++) //必须是显示申明,不能var 3 { 4   ........... 5 }

C# for循环提升效率的写法

标签:length   var   div   i++   code   很多   style   需要   for循环   

原文地址:https://www.cnblogs.com/ybqjymy/p/12170823.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!