What is literals and their types?What are the different types of literals in C#?
Answer:
Literals are value constants assigned to variables in a program. C# supports several types of literals are
Integer literals
Real literals
Boolean literals
Single character literals
String literals
Backslash character literals
Integer literals
Real literals
Boolean literals
Single character literals
String literals
Backslash character literals
Boolean literals: True and false are literals of the Boolean type that map to the true and false state, respectively.
Integer literals: Used to write values of types Int, ulnt, long, and ulong.
Real literals: Used to write values of types float, double, and dedmal.
Character literals: Represents a single character and usually consists of a character in quotes, such as 'a'.
String literals: C# supports two types of string literals, regular string literal and verbatim string literals. A regular string literal consists of zero or more characters enclosed in double quotes, such as "116110". A verbatim string literal consists of an @ character followed by a double–quote character, such as ©"hello".
The Null literal: Represents the null–type.
Integer literals: Used to write values of types Int, ulnt, long, and ulong.
Real literals: Used to write values of types float, double, and dedmal.
Character literals: Represents a single character and usually consists of a character in quotes, such as 'a'.
String literals: C# supports two types of string literals, regular string literal and verbatim string literals. A regular string literal consists of zero or more characters enclosed in double quotes, such as "116110". A verbatim string literal consists of an @ character followed by a double–quote character, such as ©"hello".
The Null literal: Represents the null–type.
No comments:
Post a Comment