Tsallaka zuwa abun ciki
Justice Tech School

C# Constants

const creates a value that cannot change after it is declared, and it must be set at compile time. Use readonly for values set once at runtime.

Example
const double Pi = 3.14159;
Console.WriteLine(Pi);
// Pi = 3; // error

Exercise

Declare a constant.

 int Max = 10;

Quiz Test

What does const do?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.