What are tokens in C#?

Token is the smallest element of a program. Let us learn about identifiers and keywords in C# that are tokens −


Keywords are reserved words predefined to the C# compiler. These keywords cannot be used as identifiers. However, if you want to use these keywords as identifiers, you may prefix the keyword with the @ character.

The following are some of the reserved keywords in C# −

foreachgotoIfimplicitInin (generic modifier)int
nullobjectoperatoroutout (generic modifier)overrideparams


An identifier is a name used to identify a class, variable, function, or any other user-defined item. The basic rules for naming classes in C# are as follows −

  • A name must begin with a letter that could be followed by a sequence of letters, digits (0 - 9) or underscore. The first character in an identifier cannot be a digit.

  • It must not contain any embedded space or symbol such as? - + ! @ # % ^ & * ( ) [ ] { } . ; : " ' / and \. However, an underscore ( _ ) can be used.

Samual Sam
Samual Sam

Learning faster. Every day.

Updated on: 21-Jun-2020

1K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started