Dauris Little
  • About
  • Blogging Lyf
  • Contact
  • Portfolio
“Never be limited by other people’s limited imaginations.” – Dr. Mae Jamison

Identifiers & Keywords

by Dauris / Thursday, 06 August 2020 / Published in .NET & .NET Core, C#, Programming Languages
.NET C#

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”

  • Tweet
Tagged under: identifiers in c#, keywords in c#
Avatar photo

About Dauris

What you can read next

Did someone say Navigation to the rescue: Android Jetpack
Creating Advance Custom Snackbar w/ Kotlin
QR Reader in Android w/ Kotlin

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

All rights reserved. 

TOP
This site uses tracking cookies to personalize content and ads. AcceptLearn More