Are there risks to optimizing code in C#?

后端 未结 8 895
粉色の甜心
粉色の甜心 2020-12-18 18:53

In the build settings panel of VS2010 Pro, there is a CheckBox with the label \"optimize code\"... of course, I want to check it... but being unusually cautious, I asked my

8条回答
  •  盖世英雄少女心
    2020-12-18 19:28

    In C# the optimization should NEVER break your code.

    Instead, with optimizations turned on the compiler produces more compact CIL when translating between C# and CIL.

    I observed (and frankly it's interesting!) that the C# compilers from .NET < 2.0 (1.0 and 1.1) produced as good CIL WITHOUT optimizations as later C# compilers (2.0 and later) produce WITH optimizations.

提交回复
热议问题