C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
Types: Types of tokens include keywords (class), identifiers (Program), literals (2) and operators (=).
Program: C#
class Program
{
static void Main()
{
int test = 2;
float item = 5.5f;
char unit = 'e';
string basic = "c#";
}
}
Tokens
class
Program
{
static
void
Main
(
)
{
int
test
=
2
;
float
item
=
5.5f
;
char
unit
=
'e'
;
string
basic
=
"c#"
;
}
}
Token types
identifier:
Identifiers are arbitrary names in your C# program.
This includes Program, Main, test, item, unit and basic.
keyword:
Many keywords are reserved by the C# language.
These include class, static, void, int, float, char and string.
integer-literal:
real-literal:
character-literal:
string-literal:
Literals are constant values you can use in your program.
These include 2, 5.5f, 'e' and "c#".
Literals include the enclosing quotation marks.
For the literal 5.5f, the numeric suffix is included in the literal.
This is a real-literal.
operator-or-punctuator:
These are characters in your program that are part of the scope
structure, or assignment and arithmetic statements.
Some operators, such as && are considered a single token.
The characters () are separate tokens.