Hi friends,
What is the difference between const and readonly keyword ?
Thanks
Diff between const & readonly keyword
3 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Javeed M ShaikhRank #839 · 2.7K reputationPosted Oct 31, 2011, 8:55 AM EDT
http://www.c-sharpcorner.com/UploadFile/sayginteh/ConstAndReadOnly11112005005151AM/ConstAndReadOnly.aspx
VulpesRank #55 · 29.2K reputationPosted Oct 31, 2011, 9:04 AM EDT
* const denotes a compile-time constant which the compiler can replace with its actual value .
* readonly denotes a runtime constant which cannot be evaluated until runtime. It must be set either within a constructor or where it is defined.
Dipal ChoksiRank #199 · 12K reputationPosted Oct 31, 2011, 9:27 AM EDT