Need a Translation?

What are the different types of literals in C#?

  • 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, uint, long, and ulong.
  • Real literals: Used to write values of types float, double, and decimal.
  • Character literals: Represents a single character and usually consists of a character in quotes, such as 'z'.
  • 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 "224568". A verbatim string literal consists of an @ character followed by a double–quote character, such as ©"hello".
  • Null literal: Represents the null–type.

No comments:

Post a Comment