📜  readonly vs const c# 代码示例

📅  最后修改于: 2022-03-11 14:49:08.605000             🧑  作者: Mango

代码示例2
A const is a compile-time constant whereas readonly allows a value to be calculated at run-time and set in the constructor or field initializer. So, a 'const' is always constant but 'readonly' is read-only once it is assigned.

Eric Lippert of the C# team has more information on different types of immutability.