December 8, 2009

CLR Data Types and more

Built-in Types Table
C# Type.NET Framework type
boolSystem.Boolean
byteSystem.Byte
sbyteSystem.SByte
charSystem.Char
decimalSystem.Decimal
doubleSystem.Double
floatSystem.Single
intSystem.Int32
uintSystem.UInt32
longSystem.Int64
ulongSystem.UInt64
objectSystem.Object
shortSystem.Int16
ushortSystem.UInt16
stringSystem.String
Source: http://msdn.microsoft.com/en-us/library/aa287910(VS.71).aspx



Range and Size
TypeRangeSize
booltrue or false (1 or 0)1 bit
sbyte-128 to 127Signed 8-bit integer
byte0 to 255Unsigned 8-bit integer
charU+0000 to U+ffffUnicode 16-bit character
short-32,768 to 32,767Signed 16-bit integer
ushort0 to 65,535Unsigned 16-bit integer
int-2,147,483,648 to 2,147,483,647Signed 32-bit integer
uint0 to 4,294,967,295Unsigned 32-bit integer
long-9,223,372,036,854,775,808 to 9,223,372,036,854,775,807Signed 64-bit integer
ulong0 to 18,446,744,073,709,551,615Unsigned 64-bit integer
TypeApproximate rangePrecision
float±1.5 × 10−45 to ±3.4 × 10387 digits
double±5.0 × 10−324 to ±1.7 × 1030815-16 digits
Source: http://msdn.microsoft.com/en-us/library/exx3b86w(VS.71).aspx and http://msdn.microsoft.com/en-us/library/9ahet949(VS.71).aspx



Default values
Value typeDefault value
boolfalse
byte0
char'\0'
decimal0.0M
double0.0D
enumThe value produced by the expression (E)0, where E is the enum identifier.
float0.0F
int0
long0L
sbyte0
short0
structThe value produced by setting all value-type fields
to their default values and all reference-type fields to null.
uint0
ulong0
ushort0
Source: http://msdn.microsoft.com/en-us/library/83fhsxwc(VS.71).aspx



Implicit Numeric Conversions Table
FromTo
sbyteshort, int, long, float, double, or decimal
byteshort, ushort, int, uint, long, ulong, float, double, or decimal
shortint, long, float, double, or decimal
ushortint, uint, long, ulong, float, double, or decimal
intlong, float, double, or decimal
uintlong, ulong, float, double, or decimal
longfloat, double, or decimal
charushort, int, uint, long, ulong, float, double, or decimal
floatdouble
ulongfloat, double, or decimal
Source: http://msdn.microsoft.com/en-us/library/y5b434w4(VS.71).aspx



Explicit Numeric Conversions Table
FromTo
sbytebyte, ushort, uint, ulong, or char
bytesbyte or char
shortsbyte, byte, ushort, uint, ulong, or char
ushortsbyte, byte, short, or char
intsbyte, byte, short, ushort, uint, ulong, or char
uintsbyte, byte, short, ushort, int, or char
longsbyte, byte, short, ushort, int, uint, ulong, or char
ulongsbyte, byte, short, ushort, int, uint, long, or char
charsbyte, byte, or short
floatsbyte, byte, short, ushort, int, uint, long, ulong, char, or decimal
doublesbyte, byte, short, ushort, int, uint, long, ulong, char, float, or decimal
decimalsbyte, byte, short, ushort, int, uint, long, ulong, char, float, or double
Source: http://msdn.microsoft.com/en-us/library/aa288039(VS.71).aspx

2 comments:

Total Pageviews