Back to directory
We need to clarify the initial values of some value types, that is, when you declare a variable, it actually has a default value.
Msdn: http://msdn.microsoft.com/zh-cn/library/83fhsxwc.aspx
Value Type |
Default Value |
Bool |
False |
Byte |
0 |
Char |
'\ 0' |
Decimal |
0.0 m |
Double |
0.0d |
Enum |
Value generated by expression (e) 0, where E is the enum identifier. |
Float |
0.0f |
Int |
0 |
Long |
0l |
Sbyte |
0 |
Short |
0 |
Struct |
Set all value type fields to default values and all reference type fieldsNullValue. |
Uint |
0 |
Ulong |
0 |
Ushort |
0 |
The following table shows the integer size and range. These types constitute a subset of simple types.
Type |
Range |
Size |
Sbyte |
-128 to 127 |
Signed 8-digit integer |
Byte |
0 to 255 |
Unsigned 8-digit integer |
Char |
U + 0000 to U + FFFF |
16-bit Unicode characters |
Short |
-32,768 to 32,767 |
Signed 16-digit integer |
Ushort |
0 to 65,535 |
Unsigned 16-digit integer |
Int |
-2,147,483,648 to 2,147,483,647 |
Signed 32-bit integer |
Uint |
0 to 4,294,967,295 |
Unsigned 32-bit integer |
long |
-9,223,372,036,854,775,808 to 9,223,372,036,854,775,807 |
signed 64 integer |
Ulong |
0 to 18,446,744,073,709,551,615 |
Unsigned 64-bit integer |
Back to directory