Naming Variables

In programming variables keep data and for the code to be more understandable the name of a variable should suggest its purpose. Here are some recommendations for naming variables:

  • The name should be short and descriptive and to explain what the variable serves for.
  • The name should only contain the letters a-z, A-Z, the numbers 0-9, and the symbol '_'.
  • It is accepted in C# for the variables to always begin with a lowercase letter and to contain lowercase letters, and each next word in them should start with an uppercase letter (this naming is also known as camelCase convention).
  • You should be careful about uppercase and lowercase letters, because C# makes a difference between them. For example age and Age are different variables.
  • The names of the variables can not coincide with keywords in the C# language, for example int is an invalid name for a variable.
Although using the symbol _ in the names of variables is permitted, in C# it is not recommended and is considered a bad style of naming.

results matching ""

    No results matching ""