C# Variables

Facebooktwitterredditpinterestlinkedinmailby feather

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 TypesDecimal
Boolean TypesTrue or False
Integral TypesInt, byte, char, long
Floating Point TypesFloat and double
Nullable TypesNullable Dtata types
Facebooktwitterredditpinterestlinkedinmailby feather

Leave a Comment