What is the key difference between const and readonly fields in C#?
Correct answer B. const is fixed at compile time; readonly can be assigned at declaration or in a constructor
A const value must be a compile-time constant and is implicitly static, so it is baked into calling code. A readonly field can be given its value in the declaration or in any constructor, so it can depend on run-time data such as DateTime.Now or a constructor argument, and different instances can hold different values. After construction neither can be reassigned.
Answer checked How we write and check questions
Discussion