Wednesday, September 23, 2009

C# - Data Types and Ranges

C# supports all the major data types and more. This page lists the most common types and the ranges of values they can hold.

All minimum and maximum values can be found using (data type).MinValue and (data type).MaxValue (e.g. int.MinValue).

Type Size[Bytes] Description Minimum Maximum Example
bool 1 Named literal false true
sbyte 1 Signed byte -128 127
byte 1 Unsigned byte 0 255
short 2 Signed short integer -32768 32767
ushort 2 Unsigned short 0 65535
int 4 Signed integer -2147483648 2147483647
uint 4 Unsigned integer 0 4294967295
long 8 Signed long int -9.2233E+18 9.2233E+18
ulong 8 Unsigned long int 0 18446E+19
char 2 Unicode character, contained 0 128 a,b,4
within single quotes.
float 4 floating point -3.402823E+38 3.402823E+38 3.14159
double 8 Floating point -1.7976931E+308 1.7976931E+308 3.14159
decimal 16 Floating point, accurate to
the 28th decimal place. -7.9228E+24 7.9228E+24
object 8+ Base type for all other types n/a n/a n/a
string 20+ Immutable character array n/a n/a "Hello World"

...

No comments:

Post a Comment

Followers