We've seen how variables are created, and touched on the high-level functionality that they provide, but we're still missing the syntax that makes all of that possible. Variables don't just appear at the top of a C# script; they have to be declared according to certain rules and requirements. At its most basic level, a variable statement needs to satisfy the following requirements:
- The type of data the variable will store needs to be specified
- The variable has to have a unique name
- If there is an assigned value, it must match the specified type
- The variable declaration needs to end with a semicolon
The result of adhering to these rules is the following syntax:
dataType uniqueName = value;
Variables need unique names to avoid conflicts with words that are already taken by C#, which are called keywords. You can find the...