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