#4 – C# Constants

In this short tutorial, you will learn the key points of C# constants.


A constant is a variable whose value cannot be changed throughout its lifetime, and it is defined with the keyword const.

const string testStr = "This is a constant";


  • Constants must be initialized when they are declared. And can never be overwritten after a value been assigned.
  • The value of a constant must be computable at compile time. As the compiler replaces the variable with its values everywhere it is used.
  • Constants are always implicitly static.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.