for and while loop in c#

前端 未结 6 1809
长情又很酷
长情又很酷 2020-12-03 05:22
for (i=0 ; i<=10; i++)
{
    ..
    ..
}

i=0;
while(i<=10)
{
    ..
    ..
    i++;
}

In for and while loop, which one is better, performanc

6条回答
  •  南方客
    南方客 (楼主)
    2020-12-03 05:43

    Program efficiency comes from proper algorithms, good object-design, smart program architecture, etc.

    Shaving a cycle or two with for loops vs while loops will NEVER make a slow program fast, or a fast program slow.

    If you want to improve program performance in this section, find a way to either partially unroll the loop (see Duff's Device), or improve performance of what is done inside the loop.

提交回复
热议问题