Skip to content
Justice Tech School

var, const and readonly

var infers a local type. const is a compile time constant and readonly can be set once in a constructor.

Example
var n = 10;
const double Pi = 3.14159;
var text = "typed as string";
Console.WriteLine($"{n} {Pi} {text}");

Exercise

Constant keyword.

 int Max = 5;

Quiz Test

Does var mean dynamic?

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