C#.NET Variables

C#.NET Variables are used to store values temporary entered by a user. Variables are the entity that may vary during program execution. In order to use a variable we have to declare a variable along with its data type.

Syntax: data_type variable_name;

Rules to declare a variable:

  1. A variable name can contain any sequence of letters (a-z, A-Z), digits (0-9), underscore (_) or @.
  2. Special characters ( ! # ( ) % ^ & * ? ), blank space ( ) or comma (,) are not allowed.
  3. The first character should be a letter, underscore or @.
  4. Upper and lower case letters are distinguishable.
  5. A Keyword cannot be used to declare a variable name.