Will my compiler ignore useless code?

前端 未结 9 1311
情深已故
情深已故 2021-02-06 21:53

I\'ve been through a few questions over the network about this subject but I didn\'t find any answer for my question, or it\'s for another language or it doesn\'t answer totally

9条回答
  •  名媛妹妹
    2021-02-06 22:00

    It won't be ignored. However, when you get to IL there will be a jump statement, so the for will run as if it was an if statement. It will also run the code for ++ and length, as @Fleve mentioned. It will just be extra code. For readability sake, as well as to keep with code standards I would remove the code if you don't use it.

提交回复
热议问题