C# Data Type Keywords Reference Sheet

The following table shows common data type keywords.

Keyword .NET Framework Type Description Value Range Variable Declaration Example
bool System.Boolean Boolean type; a bool value is either true or false. true or false bool val1 = true;
bool val2 = false;
byte System.Byte 8-bit unsigned integral type 0 to 255 byte val1 = 12;
char System.Char 16-bit unicode character 0 to 65535 char c = ‘a’;
char c = 255;
decimal System.Decimal 128-bit fixed-point decimal type with 28 significant digits -7.9e28 to 7.9e28 decimal val = 1.23M;
double System.Double 64-bit double-precision floating point type -1.79e308 to
1.79e308
double val1 = 1.23;
double val2 = 4.56D;
float System.Single 32-bit single-precision floating point type -3.40e38 to 3.40e38 float val = 1.23F;
int System.Int32 32-bit signed integral type -2,147,483,648 to 2,147,483,647 int val = 12;
long System.Int64 64-bit signed integral type -9,223,372,036,854,775,808 to
9,223,372,036,854,775,807
long val1 = 12;
long val2 = 34L;
sbyte System.SByte 8-bit signed integral type -128 to 127 sbyte val = 12;
short System.Int16 16-bit signed integral type -32,768 to 32767 short val = 12;
string System.String Immutable string of 16-bit Unicode characters All valid string characters string val = "Hello world."
uint System.UInt32 32-bit unsigned integral type 0 to 4,294,967,296 uint val1 = 12;
uint val2 = 34U;
ulong System.UInt64 64-bit unsigned integral type 0 to 18,446,744,073,709,551,615 ulong val1 = 12;
ulong val4 = 78UL;
ushort System.UInt16 16-bit unsigned integral type 0 to 65535 ushort val1 = 12;

Be aware of the following special cases when initializing data types:

  • When initializing a char, use single quotes surrounding the letter.
  • When initializing a string, use double quotes surrounding the text.
  • When initializing a value that includes the decimal point,
  • For a decimal type, follow the number with the letter M.
  • For a float type, follow the number with the letter F.
  • Under other special circumstances, you might be required to include letter values following the numeric values for other data types.