To Documents

C# Primitive Datatypes

C# Datatype Bytes Range
byte 1 0 to 255
sbyte 1 -128 to 127
short 2 -32,768 to 32,767
ushort 2 0 to 65,535
int 4 -2 billion to 2 billion
uint 4 0 to 4 billion
long 8 -9 quintillion to 9 quintillion
ulong 8 0 to 18 quintillion
float 4 7 significant digits1
double 8 15 significant digits2
object 4 byte address All C# Objects
char 2 Unicode characters
string 4 byte address Length up to 2 billion bytes
decimal 24 28 to 29 significant digits3
bool 2 true, false

The range of an unsigned integer of size n bytes is 0 to 28n - 1.

The range of a signed integer of size n bytes is -28n-1 to 28n-1 - 1.

1For the float datatype, positive values are 1.4 x 10-45 to 3.4 x 1038.
Negative values are -3.4 x 1038 to -1.4 x 10-45.

2For the decimal datatype, positive values are 4.9 x 10-324 to 1.8 x 10308.
Negative values are -1.8 x 10308 to -4.9 x 10-324

3For the decimal datatype, positive values are 1.0 x 10-28 to 7.9 x 1028.
Negative values are -7.9 x 1028 to -1.0 x 10-28.