Possible Duplicate:
What is the difference between const and readonly?
are these interchangeable? can you show me code on how you would apply the two?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
No, they aren’t.
A
constfield is literal value embedded in the assembly.Only primitive values (strings and numbers) can be
const, and they are evaluated at compile time.When you reference a
constfield, the compiler embeds the literal value of the field. Therefore, if use use aconstfrom another assembly, and the other assembly is recompiled with a different value, your assembly will only use the new value if you recompile it against the new version.A
readonlyfield is a normal field that cannot be changed outside the constructor.