A literal is a textual representation of a particular value of a type.
The different types of literals in Visual Basic are:
- Boolean Literals – Refers to the True and False literals that map to the true and false state, respectively.
- Integer Literals – Refers to literals that can be decimal (base 10), hexadecimal (base 16), or octal (base 8).
- Floating-Point Literals – Refers to an integer literal followed by an optional decimal point By default, a floating-point literal is of type Double.
- String Literals – Refers to a sequence of zero or more Unicode characters beginning and ending with an ASCII double-quote character.
- Character Literals – Represents a single Unicode character of the Char type.
- Date Literals – Represents time expressed as a value of the Date type.
- Nothing – Refers to a literal that does not have a type and is convertible to all types in the type system.
The different types of literals in C# are:
- Boolean literals – Refers to the True and False literals that map to the true and false states, respectively.
- Integer literals – Refers to literals that are used to write values of types int, uint, long, and ulong.
- Real literals – Refers to literals that are used to write values of types float, double, and decimal.
- Character literals – Represents a single character that usually consists of a character in quotes, such as ‘a’.
- String literals – Refers to string literals, which can be of two types in C#:
- A regular string literal consists of zero or more characters enclosed in double quotes, such as “hello”.
- A verbatim string literal consists of the @ character followed by a double-quote character, such as @”hello”.
- The Null literal – Represents the null-type.