Identifiers C#
Identifiers are the name given to entities such as variables, methods, classes, etc. They are tokens in a program which uniquely identify an element. For example,
int value
From code above value
is the variable which is why we call it the identifier. As you will find out later int is consider a “reserved” keyword so should not be used as an identifier unless the prefix @
is present.
Naming Conventions Rule Of Thumb
- Keywords should not be identifiers
- No whitespaces
- Case sensitivity : so
firstname
Firstname
firstName
FirstName
these are 4 different identifiers - Must begin with a letter, underscore or
@
Keywords C#
Keywords are predefined sets of reserved words that have special meaning in a program. The meaning of keywords can not be changed, neither can they be directly used as identifiers in a program. For example,
long phoneNumber
From the code above long
is considered the keyword whilephoneNumber
is the variable or the identifier. In C# long
has a special meaning. Keywords such as long, int, bool, string etc are not allowed to be used as identifiers. However when there is a will then we have a way so even though keywords are “reserved” words, tha can be used as indentifiers if you add @
as the prefix long @int
Note: Though you can use the prefix
@
I suggest as good practice and coding etiquette that you do not do that. It is what we call bad “juju”