Information Technology Reference
In-Depth Information
More About the Predefined Types
All the predefined types are mapped directly to underlying .NET types. The C# type names are
just aliases for the .NET types, so using the .NET names works fine syntactically, although this
is discouraged. Within a C# program, using the C# names is preferred to using the .NET names.
The predefined simple types represent a single item of data. They are listed in Table 3-1,
along with the ranges of values they can represent and the underlying .NET types to which
they map.
Table 3-1. The Predefined Simple Types
Name
Meaning
Range
.NET Framework Type
sbyte
System.SByte
8-bit unsigned integer
-128-127
byte
8-bit unsigned integer
0-255
System.Byte
short
System.Int16
16-bit unsigned integer
-32,768-32,767
ushort
16-bit unsigned integer
0-65,535
System.UInt16
int
System.Int32
32-bit signed integer
-2,147,483,648-2,147,483,647
uint
32-bit unsigned integer
0-4,294,967,295
System.UInt32
long
System.Int64
64-bit signed integer
-9,223,372,036,854,775,808 to
9,223,372,036,854,775,807
ulong
System.UInt64
64-bit unsigned integer
0-18,446,744,073,709,551,615
10 -45 -3.4
10 38
float
Single-precision float
1.5
×
×
System.Single
double
10 -324 -1.7
10 308
System.Double
Double-precision float
5
×
×
bool
Boolean
true , false
System.Boolean
char
System.Char
Unicode character
U+0000-U+ffff
10 28 -±7.9
10 28
decimal
Decimal value with
28-significant-digit
precision
±1.0
×
×
System.Decimal
The non-simple predefined types are somewhat more complex. Values of type string con-
tain zero or more Unicode characters. The object type is the base class for all other types in the
system, including the predefined, simple types. These are shown in Table 3-2.
Table 3-2. The Predefined Non-Simple Types
Name
Meaning
.NET Framework Type
object
System.Object
The base class from which all other types are derived.
string
A sequence of Unicode characters.
System.String
Search WWH ::




Custom Search