Differentiate between constants and read-only variables.

  1. Constants
  • Evaluated at compile time.

  • Support only value type variables.

  • They are used when the value is not changing at compile time.

  • Cannot be initialized at the time of declaration or in a constructor.

       2.Read-only Variables

  • Evaluated at run-time
  • They can hold the reference type variables
  • Used when the actual value is unknown before the run-time
  • Can be initialized at the time of declaration or in a constructor
Posted on by