Thursday, October 20, 2011

1.6. Identifiers

The acceptable names for variables (which are known as "identifiers") may consist of letters, numbers or the underscore (_) and must start with letter or underscore. They must not have spaces in between, and accented vowels and "ñ" are not "standard" characters accepted in all languages, so in most occasions they should not be used.

Therefore, these are not valid variable names:

1number (starts with number)
a number (contains a space)
Año1 (contains a "ñ")
MásDatos (has a stressed vowel)
Also, we cannot use C# reserved words as identifiers. For example, the word "int" refers to a certain data type that we can use for variables, so the word "int" may not be used as a identifier (we will not include a list of C# reserved words yet)

For now, we will try to use variable names that seem readable to us, and that seem not to be a C# command.

We must remember that in C# upper case and lower case letters are not interchangeable, so if we try to do

FirstNumber = 0;
firstnumber = 0;

or any similar variation, the compiler will complain and tell us that such variables are unkown, because we declared

int firstNumber;

No comments:

Post a Comment