Constant value not changing when recompiling referenced assembly

后端 未结 2 828
日久生厌
日久生厌 2020-12-20 13:33

I have this code in an assembly:

public class Class1
{
    public const int x = 10;
}

and in a different assembly I have:<

2条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-20 14:11

    This is a technique called constant folding used in compiling. In short, the compiler look for values that can be determined at compile time, computes those values, and write them directly in the exe file. This speeds up the execution of the final machine code. This technique applies to other many compiled languages, such as C, C++ as well.

提交回复
热议问题