Today I found an article where the const field is called the compile-time constant, and the readonly field is called the run-time constant. Two phrases taken from Effective C #. I searched the MSDN and language specifications, found nothing about the runtime constant.
Not offensive, but I don't think the runtime constant is the right phrase.
private readonly string foo = "bar";
creates a variable called "foo" whose value is "bar", and the value is read-only, here it is a variable that has nothing to do with constant . The readonly variable is still a variable; it cannot be a constant. Variables and constants are mutually exclusive.
Perhaps this question goes overboard, but I want to listen to the opinions of others. What do you think?
Cheng chen
source share