C#'s const vs. readonly

A quick synopsis on the differences between 'const' and 'readonly' in C#:

'const':
  • Can't be static.
  • Value is evaluated at compile time.
  • Initiailized at declaration only.
'readonly':
  • Can be either instance-level or static.
  • Value is evaluated at run time.
  • Can be initialized in declaration or by code in the constructor.

6 Comments

Comments have been disabled for this content.