Friday, October 19, 2007

.NET Value Types

Value types in .NET

The following are the built-in value types in .NET. Value types are stored on the stack and can be accessed more efficiently than reference types.

Type: SByte
Alias(es): sbyte
Size (in bytes): 1
Range: -128 to 127

Type: Byte
Alias(es): byte
Size (in bytes): 1
Range: 0 to 255

Type: Int16
Alias(es): Short, short
Size (in bytes): 2
Range: -32768 to 32767

Type: Int32
Alias(es): Integer, int
Size (in bytes): 4
Range: -2147483648 to 2147483647

Type: UInt32
Alias(es): UInteger, uint
Size (in bytes): 4
Range: 0 to 4294967295

Type: Int64
Alias(es): Long, long
Size (in bytes): 8
Range: -9223372036854775808 to 9223372036854775807

Type: Single
Alias(es): float
Size (in bytes): 4
Range: -3.402823E+38 to 3.402823E+38

Type: Double
Alias(es): double
Size (in bytes): 8
Range: -1.79769313486232E+308 to 1.79769313486232E+308

Type: Decimal
Alias(es): decimal
Size (in bytes): 16
Range: -79228162514264337593543950335 to 79228162514264337593543950335

Type: Char
Alias(es): char
Size (in bytes): 2

Type: Boolean
Alias(es): bool
Size (in bytes): ?
Range: true, false

Type: IntPtr
Size (in bytes): Platform-specific

Type: DateTime
Alias(es): Date, date
Size (in bytes): 8
Range: 1/1/0001 12:00:00 AM to 12/31/9999 11:59:59 PM

Operations with Int32, UInt32 and Double types are optimized by the runtime or the hardware.

No comments: