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?
No, they aren't.
A const field 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 const field, the compiler embeds the literal value of the field. Therefore, if use use a const from 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 readonly field is a normal field that cannot be changed outside the constructor.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With