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
Although the answer that Julio provided is valid from the effects of setting a variable as a constant or a read only, there are a great deal of difference between the two declarations.
While many people simply state the obvious that the value of a constant is resolved at the compilations, while a read only value will be resolved only during the run time, the main point resides where the reference is quept.
Depending on the data type of the constant, it will be either replaced at the command evocation, or stored in the HEAP and referenced by a pointer.
For instance, the code:
const int x = 3;
int y = 3 * x;
may be resolved at the compilation time as simply:
int y = 3 * 3;
On the other hand a read only field is always stored on the STACK and referenced by a pointer.