Skip to content

Const vs Static vs Readonly

Here's what you need to know about using const, static, and readonly:

  1. If you know the value will never, ever, ever change for any reason, use const. (Other Assemblies that use this value need to be recompiled before they get the new value)
  2. If you're unsure of whether or not the value will change, but you don't want other classes or code to be able to change it, use readonly.
  3. If you need a field to be a property of a type, and not a property of an instance of that type, use static.
  4. A const value is also implicitly static.