C# Foundations · Lesson 2

Variables

var stores a value under a name you can use again.

How it works

The name on the left is what later lines can read. count starts at 3. The next line reads that 3, adds 1, and stores 4 back into the same name. WriteLine prints the current value, so the output is 4, not 3.

A working example

var count = 3;
count = count + 1;
Console.WriteLine(count);

Expected output

4
Try this
Read the right-hand side first, then the name on the left.