What does compile time 'const' mean?

后端 未结 6 1439
执笔经年
执笔经年 2020-12-10 14:49

They say the difference between readonly and const is that const is compile-time (while readonly is run time). But what exactly does that mean, The fact that it\'s compile t

6条回答
  •  半阙折子戏
    2020-12-10 15:05

    A const can only be defined during its declaration. A readonly can be defined during its declaration or in a constructor. So a readonly variable can have different values according to the constructor used to initialize it.

提交回复
热议问题