Knowledge Check - Variables
1. Name the three things all variables have.
All C# variables have a name, a type, and a value. The name is how you refer to it in code, and tell it apart from another variable. The type indicates what type of data can be stored in the variable. The value is the contents of the variable.
2. True/False. All variables must always be declared before being used.
True. You can only use a variable on or after the line it is used.
3. Can you redeclare a variable?
No. You can only declare a variable once. However, you can assign values to variables as many times as you want.
4. Which of the following are legal C# variable names?
PI all follow the rules. A variable cannot begin with a
1stValue is not legal. A variable cannot contain the
$ symbol, so
not legal. A variable cannot contain a
delete-me is not legal.