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 .


Rules for defining C# variable name:

  1. A variable name can include an alphabet, a digit and an underscore.
  2. It can’t contain any special character in it.
  3. A variable name can start with an alphabet or underscore .
  4. It can’t start with a digit or any special character.
  5. No white space is allowed within the name.
  6. The name can’t be a keyword or any reserved word.

Valid variable name

int a;

int Ayush;

int _unit;

int a_1;

Invalid Variable Name

int 1a;

int a*n;

int unit 1;

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

Pin It on Pinterest

Share This