To C#-1 Notes

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 bytes3
decimal 24 28 to 29 significant digits4
bool 1 true, false5
DateTime
 
8
 
0:00:00am 1/1/01 to
11:59:59pm 12/31/9999
DateSpan
 
 
 
-10675199.02:48:05.4775808 to
10675199.02:48:05.47758076

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

The range of an unsigned 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 double 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

3A string variable in C# cannot be declared as fixed length.

4For 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.

5false is represented internally by 0, true is represented by 1.

61.23:45:67.9999999 means 1 day, 23 hours, 45 minutes, 67.9999999 seconds.