ECMA-334 C# Language Specification9.4.4.4: Character literals |
A character literal represents a single character, and usually consists of a character in quotes, as in 'a'.
'
character
'
single-character
simple-escape-sequence
hexadecimal-escape-sequence
unicode-escape-sequence
new-line-character
\'
\"
\\
\0
\a
\b
\f
\n
\r
\t
\v
\x
hex-digit
hex-digit
opt hex-digit
opt hex-digit
optA hexadecimal escape sequence represents a single Unicode character, with the value formed by the hexadecimal number following "\x".
If the value represented by a character literal is greater than U+FFFF, a compile-time error occurs.
A Unicode character escape sequence (9.4.1) in a character literal must be in the range U+0000 to U+FFFF.
A simple escape sequence represents a Unicode character encoding, as described in the table below.
The type of a character-literal
is char .