Coding in C# — What is a variable?

A variable can be thought of as a box that has information in it. Think of a game that you play, it may have your name, your avatars name, ammo count and so forth. These are all variables.

There are three (3) data types of variables, with an optional Fourth. They are:

There are also two (2) types of reference for a variable. These are:

public- anyone and any other script can access this variable. It will also be seen in the Unity editor.

private- only the script the variable is in can access it.