C# Variables
A variable is a symbol used to store user’s data. It represents a memory location. Its value can be changed multiple times and can be reused many times.
Example:
int a; //integer variable float b=3.2; //floating point variable which is initializing to some valueRules for defining C# variable name:
- A variable name can include an alphabet, a digit and an underscore.
- It can’t contain any special character in it.
- A variable name can start with an alphabet or underscore .
- It can’t start with a digit or any special character.
- No white space is allowed within the name.
- The name can’t be a keyword or any reserved word.
Variable Type | Example |
Decimal Types | Decimal |
Boolean Types | True or False |
Integral Types | Int, byte, char, long |
Floating Point Types | Float and double |
Nullable Types | Nullable Dtata types |