Monday, May 13, 2013

What is the difference between constant and readonly?


Constant
  • Its value is determine at compilation time and embedded in the IL.
  • Set at compilation time.
  • Can only for define for primitive type.
ReadOnly
  • Its value is initialized at the run-time inside the constructor.
  • Set during run-time.
  • Can be define for value type and reference type.

No comments:

Post a Comment